mIRC Home    About    Download    Register    News    Help

Print Thread
#140723 29/01/06 01:26 AM
Joined: Aug 2005
Posts: 30
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Aug 2005
Posts: 30
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

#140724 29/01/06 01:32 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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

#140725 29/01/06 01:37 AM
Joined: Aug 2005
Posts: 30
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Aug 2005
Posts: 30
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.

#140726 29/01/06 01:44 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I doubt you would be able to detect the greater cpu cycles used by the suggested code, when used in realistic testing.

#140727 29/01/06 03:15 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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

#140728 29/01/06 03:22 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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 / /.


Gone.

Link Copied to Clipboard