HOWEVER, what you appear to be missing is that the /expression/ syntax doesn't adhere to normal parsing rules already. Does the expression /%temp/ evaluate the %temp variable or match the string "%temp"? Does the [ ] define character sets or force evaluation? Does $+ concatonate? If all of these don't have their script meaning then why should I expect ()'s to be handled differently until the terminating / is encountered? Its a bug... deal with it.

Umm, what on earth are you talking about? Anything inside the pattern is evaluated and THEN passed to PCRE. $regex() parameters are treated in the same way as with every other identifier. Whatever rules define the evaluation of variables/identifiers present in parameters generally apply to $regex too.


I think that actually worked (which surprised me) but you missed the point because its NOT extendable to ANYTHING more complex than a single character... Try these...

//var %a teststring | echo -a $regex(TEST, %a, /(test)st(dd)?(ring)/) | echo a $regml(TEST, 2)
//var %a teststddring | echo -a $regex(TEST, %a, /(test)st(dd)?(ring)/) | echo a $regml(TEST, 2)


Your point? You did the same thing like in your first post: the "?" is outside the capturing subpattern. This is NOT what I proposed as a solution. This is:
//var %a teststring | echo -a $regex(TEST, %a, /(test)st((?:dd)?)(ring)/) | echo a $regml(TEST, 2)
//var %a teststddring | echo -a $regex(TEST, %a, /(test)st((?:dd)?)(ring)/) | echo a $regml(TEST, 2)

The 'secret' is to use the quantifier INSIDE the capturing subpattern: for complex subpatterns, just enclose them in a non-capturing brackets pair (the (?:) element) and apply the quantifier to it.


Or for a PERFECT example... try this:
//var %a teststringring | echo %a $regex(TEST, %a, /(test)st(dd)?(ring)\3/) | echo a $regml(TEST, 3)
You'll note that \3 (which is the 3rd left paren subexpression correctly matches "ring") and thus it returns a successful match against its input but attempts to access the 3rd match field returns nothing.


You're correct on this one actually, there is indeed a difference between \3 and $regml(3). Apparently, \3 refers to the 3rd subpattern used, even if a previous subpattern matched zero times (because of a "?" quantifier). However, I think this difference between \3 and $regml(3) is intentional: mirc doesn't fill $regml(N) in some tricky way, it just receives pointers from PCRE. If you think this is a bug (I don't), blame PCRE.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com