mIRC Home    About    Download    Register    News    Help

Print Thread
Add the repeating operator to the regex engine #175415 22/04/07 02:17 PM
Joined: Apr 2007
Posts: 3
U
unkNownn Offline OP
Self-satisified door
OP Offline
Self-satisified door
U
Joined: Apr 2007
Posts: 3
One thing I have been frustrated about for a long time is the lack of the repeating operator (syntax being: {min,max} in the regex engine. It would be wonderful if you could add that to the regex engine in mIRC. For more info see http://www.regular-expressions.info/repeat.html

Khaled, your program is great. Keep up the good work!

Re: Add the repeating operator to the regex engine [Re: unkNownn] #175416 22/04/07 02:22 PM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
It works fine, you just have to enclose it inside capturing brackets or put the regex in a variable first. This is because mIRC sees the , as an argument separator for the identifier.

Method 1: //echo -a $regex(abc,/(?:.{1,3})/)

Method 2: //var %re = /.{1,3}/ | echo -a $regex(abc,%re)

Re: Add the repeating operator to the regex engine [Re: unkNownn] #175417 22/04/07 02:28 PM
Joined: Feb 2006
Posts: 546
J
jaytea Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
mirc's regex libraries already support the {N,M} quantifier!

Code:
//var %regex = /lo{1,5}l/ | echo -a $regex(looool,%regex)


i suspect you're having trouble with that comma, trying to plug it into the regex directly:

Code:
//echo -a $regex(looool,/lo{1,5}l/)


reason that doesn't work is pretty much the same effect as putting a comma directly into any other identifier. in the above, $regex() is passed 3 parameters, name = looool, string = /lo{1 and regex = 5}l/

there's a workaround, you can put the comma inside a group of parentheses:

Code:
//echo -a $regex(looool,/(?:lo{1,5}l)/)


if enclosed in (), the comma is no longer seen as a parameter separator :>


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Re: Add the repeating operator to the regex engine [Re: jaytea] #175419 22/04/07 02:41 PM
Joined: Apr 2007
Posts: 3
U
unkNownn Offline OP
Self-satisified door
OP Offline
Self-satisified door
U
Joined: Apr 2007
Posts: 3
Hm, maybe. But it would be usefull if we didn't have to do all that work grin

Re: Add the repeating operator to the regex engine [Re: unkNownn] #175450 22/04/07 08:22 PM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
It's really not possible not to, since mIRC wouldn't be able to tell whether you're passing a name, a string and expression, or just a string and expression.