mIRC Home    About    Download    Register    News    Help

Print Thread
#207089 05/12/08 08:29 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
Hi,

I want to echo/aline all matching lines to an @window

I want to match any lines which have -XX- in them this could be -FR- , -IT- , -GR- etc. - what is the regexp for this?

firefox #207091 05/12/08 09:35 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
for a "wildmatch" of -xx-, where each x is an uppercase letter:
/-[A-Z]{2}-/

Horstl #207095 05/12/08 10:11 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
ok and is this correct

for both cases /-[A-Z]{2}-/i

for 2 or 3 letter matches /-[A-Z]{2-3}-/


firefox #207096 05/12/08 10:22 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Yes, the /i switch is for case insensitive matches.

"X to Y occurances", is: {X,Y}

Note that while you can use a regex containing commas in commands like /filter directly, for $regex() you have to store the regular expression first in a variable or the like, because the comma char is part of the $regex syntax itself. For example:
Code:
var %reg = /-[A-Z]{2,3}-/i
if ($regex(sometext,%reg)) { do stuff }

smile

Horstl #207112 06/12/08 05:40 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
ok thank you Horstl

also I know there are options in mirc for showing joins/parts etc. in channel or in status window

on one network in a certain channel there are hundreds of users - a lot more than have been in channels I have frequented before - is there a way to just ignore joins/parts for 1 specific channel - I would like the others to remain as they are now showing join/part in the channel

firefox #207113 06/12/08 05:45 PM
Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Originally Posted By: firefox
is there a way to just ignore joins/parts for 1 specific channel

Right-click the channel button and go to Events...

5618 #207114 06/12/08 05:49 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
cool thanks 5618 - didn't know that was just for one channel

edit: also in regards to the first post once I have matched say -FR- once - can I then ignore it and only match different ones say as -AB- , -CD- etc.

I was thinking something such when it matches something:

var %skip %skip $regml(1)

and then next time it triggers if $regml(1) isin %skip then halt

is this a good way?


Last edited by firefox; 06/12/08 05:57 PM.
firefox #207115 06/12/08 07:06 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
After -FR- was matched once, do you want to skip all -FR- until something that is not -FR- appears? Or do you want to skip all -FR- for a certain duration? Skip it globally, or per channel? Does case matter (shall a match on -FR- skip subsequent -Fr-)?

Horstl #207116 06/12/08 08:44 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
Originally Posted By: Horstl
After -FR- was matched once, do you want to skip all -FR- until something that is not -FR- appears? Or do you want to skip all -FR- for a certain duration?
Yes skip it until something else shows not for a certain duration
Originally Posted By: Horstl
Skip it globally, or per channel? Does case matter (shall a match on -FR- skip subsequent -Fr-)?
I am only doing it in one channel so don't think it matters, Yes skip -Fr- aswell

firefox #207117 06/12/08 09:08 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Then you don't need to store multiple items, just the last match in - for examle - a global variable. (The round brackets arround [A-Z]{2,3} capture the matched letters for the back reference $regml(1) )

Code:
; example for an on text event
on *:text:*:#YOURCHAN: {

  ; if the text contains -xx- or -xxx-  (each x is a letter, case insensitive)
  ; and the maching letters are not marked for skip
  var %reg = /-([A-Z]{2,3})-/i
  if ($regex($1-,%reg)) && (%skip != $regml(1)) { 

    ; mark the (new) match for skip
    set -e %skip $regml(1)

    ; and execute some commands
    ; - YOUR CODE HERE -

  }
}


Horstl #207167 08/12/08 03:40 PM
Joined: Sep 2007
Posts: 202
F
firefox Offline OP
Fjord artisan
OP Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
thank you Horstl

another question: what is the regexp for matching

-(somenumbers)-
-(somenumbersandletters)-

but don't match -(someletters)-

so for example match -(123456789)-
-(67)-
-(abc123)-
-(123we)-
but don't match -(abcd)-
-(efghijk)-

is this possible?

firefox #207174 08/12/08 07:29 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
I cannot think of a regex for this task at the moment, albeit it may be possible with some clever lookarounds or the like smile . I can only propose the following:
1) match "numbers and/or letters"
2) check the captured part of matches for "is not only letters"
Code:
; match one or more letters/digits enclosed in "-", capture the letters/digits
if ($regex(SOMETEXT,/-([a-z0-9]+)-/ig)) {
  ; loop captured matches
  var %n = 1
  while ($regml(%n)) {
    ; capture isn't letters only
    if ($v1 !isalpha) {
      ECHO -a do something with capture $v1
      break
    }
    inc %n
  }
}

If you apply this code on: " Test-ing-it -a5B-Foobar --XX7C--5-! " for example, it will process "a5B" (because "ing" is skipped for being only letters) and stop. If you want to process the subsequent matches "XX7C" and "5" as well, remove the "break" command in the while loop.
_________
EDIT

Note that the regex above "consumes" alle the "-"chars while matching. Using the snippet above, a check on
Code:
-ing-5-a5-1z-zz-1z-
will only process "a5":
- "-ing-" is matched first, including it's leading and trailing "-"
- "-ing-" is skipped in processing, for being letters only
- the check now continues at "5- ..." (not at "-5- ...")
- thus "-a5-" is matched and will be processed
- the regex now continues at "1z- ...", therefore
- the next match is -zz-, which is skipped ... etc

You can use lookarounds to prevent the "consumption" of the "-"chars in the matching:
if ($regex(SOMETEXT,/(?<=-)([a-z0-9]+)(?=-)/ig)) {

... will process the second match "5" (the first match that passes the !isalpha condition). And if you didn't use /break, the "a5" "1z" and again "1z" as well.

You'll find a better explanation of lookarounds here


Link Copied to Clipboard