mIRC Home    About    Download    Register    News    Help

Print Thread
$regmlex index without /F #267586 14/08/20 12:28 PM
Joined: Jul 2006
Posts: 3,715
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,715
After a call such as $regex(b,/(a)?(b)/g), $regmlex(1,0) is set to 1, which, given the fact /F is not used, can be viewed as correct.

However $regmlex(1,1) is $null and $regmlex(1,2) is 'b', and that defies logic if $regmlex(1,0) reports 1.

This was found after a person was trying to figure out if a given capture group being reported was participating in the match, an information that can be useful when debugging.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $regmlex index without /F [Re: Wims] #267588 15/08/20 02:20 PM
Joined: Dec 2002
Posts: 4,795
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,795
Thanks for your bug report. This is one of the issues that /F was intended to resolve. $regmlex() does not just contain a list of items that you iterate through, it contains a list of items that are marked with the match and group values that PCRE returns during its search. In this case, $regmlex(1,0) is returning the actual number of matches returned by PCRE (when /F is not used). When you try to match $regmlex(1,1), $regmlex() does not contain any items that match that group. On the other hand, $regmlex(1,2) will find that group. So, yes, there is a disparity when /F is not used. That is why /F should always be used. Ideally, /F should be the default behaviour, however at the time that /F was added, the number of backward compatibility issues with older scripts was deemed too great, so it was added as an option.

Re: $regmlex index without /F [Re: Khaled] #267590 17/08/20 02:09 PM
Joined: Jul 2006
Posts: 3,715
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,715
I see. I can only hope it was not made a list so that named capturing group can also be used there wink (here and here)


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net