mIRC Home    About    Download    Register    News    Help

Print Thread
$regex and $regsub return -8 #116176 03/04/05 06:42 AM
Joined: Aug 2003
Posts: 314
S
Sigh Offline OP
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
On mIRC 6.16, Windows XP

In older versions of mIRC where certain expressions testing certain strings would cause it to hang for a while but still return a correct result, on 6.16 it seems to "give up" after about 1.3 seconds (on my machine) and return a value of -8

Code:
//echo -a $regex($str(1,30),(\d.*){30})


Of course the workaround in this particular case is $iif($regex($str(1,30),/\d/g) > 29,1,0) but it's just an example

Could this be intended behavior, returning -8 rather than hang for an unwanted amount of time? The change isn't mentioned in versions.txt so it wouldn't appear so. The same behavior is seen when using $regsub

Re: $regex and $regsub return -8 #116177 03/04/05 03:04 PM
Joined: Apr 2003
Posts: 701
K
Kelder Offline
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
I agree it would be best if there was some mention of aborting regexes that take too long, like is apparently happening.

But I don't understand why you would need or want to use regexes that have a clear problem with those situations.

How about using one of these (according to your needs):
- a series of 30 or more digits: \d{30}
- 30 or more digits with other text inbetween:
(?:\d\D*?){30}
(?:\d+?\D*?){30}
- same, but store last match (and erverything behind it) in $regml(1): (?:\d\D*?){29}(\d+?\D*)
- 30 or more groups of digits between other text
(?:\d+?\D+){30}
(?:\d+?\D+?){30}

Re: $regex and $regsub return -8 #116178 03/04/05 10:19 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Not related to your bug report, but in this particular case you could simply do an ungreedy match: (\d.*?){30}

Nevermind, just noticed you said 'just an example'

Last edited by qwerty; 03/04/05 10:21 PM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: $regex and $regsub return -8 #116179 17/04/05 03:06 AM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Quote:
Could this be intended behavior, returning -8 rather than hang for an unwanted amount of time? The change isn't mentioned in versions.txt so it wouldn't appear so. The same behavior is seen when using $regsub


The -8 might stand for the PCRE_ERROR_MATCHLIMIT, which is a return value from pcre_exec()
that means the recursion and backtracking limit was reached.

The example you used to showcase the bug report has some serious backtracking, which might explain it. I get it on any pattern with extreme backtracking, fex:

$regex($str(z,25),/(z*)*[bc]/)

etc.

Greets


Gone.