mIRC Homepage
Posted By: Sigh $regex and $regsub return -8 - 03/04/05 06:42 AM
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
Posted By: Kelder Re: $regex and $regsub return -8 - 03/04/05 03:04 PM
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}
Posted By: qwerty Re: $regex and $regsub return -8 - 03/04/05 10:19 PM
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'
Posted By: FiberOPtics Re: $regex and $regsub return -8 - 17/04/05 03:06 AM
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
© mIRC Discussion Forums