mIRC Homepage
Posted By: SnakeBite34 $me regex - 29/01/06 01:26 AM
I tried the following on text event:
on $*:TEXT:m/(snake| $+ $replace($me,[,\[,],\]))/:#:echo -s TEST COMPLETE

It didn't work somehow, but somehow
//echo -ag $regex($me,snake| $+ $replace($me,[,\],[,\[))
would return 1
Is there a workaround? I also tried it with
on *:TEXT:$($regex($me,snake| $+ $replace($me,[,\],[,\[)))
and that didn't work either
Posted By: genius_at_work Re: $me regex - 29/01/06 01:32 AM
on *:TEXT:*:#:{
;make regex
var %r = /(snake| $+ $replace($me,[,\[,],\]) $+ )/
;if regex fails, stop here
if (!$regex(,$1-,%r)) return

;rest of code goes here

}

-genius_at_work
Posted By: SnakeBite34 Re: $me regex - 29/01/06 01:37 AM
The reason I had a specific event is so I wouldn't have an event trigger when there's nothing to match, so it's just wasting cpu.
Posted By: DaveC Re: $me regex - 29/01/06 01:44 AM
I doubt you would be able to detect the greater cpu cycles used by the suggested code, when used in realistic testing.
Posted By: genius_at_work Re: $me regex - 29/01/06 03:15 AM
I don't know if $identifiers are allowed in event regex matches.. this might work:

on $*:TEXT:m/(snake| $+ $replace($me,[,\[,],\]) $+ )/:#:echo -s TEST COMPLETE

You may run into problems if there are other special regex characters in your $me, such as (){}\.*+?$^ . If $ids are allowed, you could make a custom alias to escape all non-alnum chars. Something like this

alias escape {
var %s, %r = $regsub(,$$1-,/[^ \w]/g,\\\1,%s)
return %s
}

(untested)

-genius_at_work
Posted By: FiberOPtics Re: $me regex - 29/01/06 03:22 AM
You need to use $() to let identifiers evaluate in the matchtext part. This means putting the entire expression within $(), not just the identifier. There's no need for the m either, since you're using the default regex delimiters / /.
© mIRC Discussion Forums