mIRC Home    About    Download    Register    News    Help

Print Thread
#149384 17/05/06 08:42 PM
Joined: May 2006
Posts: 1
T
Terrab Offline OP
Mostly harmless
OP Offline
Mostly harmless
T
Joined: May 2006
Posts: 1
I am trying to use non-capturing parenthesis in an on-text regex:
Code:
on $*:text:/^[+-](.+?)(?: (.+))?$/:#: {

but it fails every time. I tried:
Code:
$regex(+Command params,/^[+-](.+?)(?: (.+))?$/)

and it matched just fine.

Could some one tell me why this isn't working?

Thanks.
-Terrab

#149385 17/05/06 11:32 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
The : is a special character in event definitions, so you cannot use the non-capturing ?:

#149386 20/05/06 03:40 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
You can't use : directly in an event for the reason hixxy gave, however you can use $() around the matchtext to make mIRC evaluate it beforehand so that you can use $chr(58) in place of :.

ie.
Code:
on $*:text:/^[+-](.+?)(?[color:red] $+ $chr(58)[/color] (.+))?$/:#: {


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#149387 20/05/06 03:53 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
I never thought of doing that before. Good idea.


Link Copied to Clipboard