mIRC Home    About    Download    Register    News    Help

Print Thread
#267586 14/08/20 12:28 PM
Joined: Jul 2006
Posts: 4,146
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
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.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Dec 2002
Posts: 5,412
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,412
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.

Joined: Jul 2006
Posts: 4,146
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
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)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard