mIRC Home    About    Download    Register    News    Help

Print Thread
#205667 28/10/08 12:36 AM
Joined: Mar 2008
Posts: 47
N
nok Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Mar 2008
Posts: 47
The following code is valid? I am not very good with $regex blush
Code:
ON ^*:TEXT:*:*:{  
  if ($regex($strip($1-),/\b( $+ $me $+ )(\b)/i)) {
    echo -i2ces nick * $asctime(HH:nn) # $nick : $1- 
    flash -w 
  } 
}

THX grin

nok #205668 28/10/08 12:52 AM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
technically, it is smile
Some notes:

- you don't need to "capture" the regex match (using brackets) if you don't need references or the like. for a "is/aint matching my nick on word boundaries" check, the regex /\b $+ $me $+ \b/ will suffice

- instead of using $strip, you can use the S switch, e.g. $regex(unstripped text,/yourregex/iS)

- you're using * for the target (matching both channels and private messages) but use # (chan) in the echo part

- you don't need the ^ event prefix if you don't intend to "halt/haltdef" the text

- it's possible (but not needed of course) to use a regex in the matchtext definition of the on text event itself (using the $ event prefix). e.g.:
Code:
on $*:text:$($+(/\b,$me,\b/Si)):*: { stuff }

(the extra $() evaluation is needed in this example case)


nok #205670 28/10/08 01:13 AM
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Code:
on $*:TEXT:$($+(*,$me,*)/iS):*: { echo -ices * $asctime(HH:nn) # $nick : $1- | flash -w }


I suppose this should work too.

Last edited by Tomao; 28/10/08 01:20 AM.
Tomao #205676 28/10/08 12:52 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
It won't, as a regex in the matchtext HAS to be enclosed in /regex/. Your code is translated to *nick*/iS instead. In addition, a word boundary isn't the same as a wildcard, and the regex equivalent of "wildcard asterisk" is .* (zero or more occurances of any char), not * smile


Link Copied to Clipboard