but you are completely ignoring the fact that I wish to test whether a subexpression matched by examining $regml(). Your solution expressly forbids this!
Again, I don't think you understood me, since my solution permits exactly this... Here's another example:
//echo -s $regex(ad,/(a)(bc)?(d)/) : $regml(0) - $regml(1) - $regml(2) - $regml(3)
You claim that you can't know if (bc) matched because $regml(0) returns 2 and $regml(2) returns "d", right?
My solution to this problem was this:
//echo -s $regex(ad,/(a)((?:bc)?)(d)/) : $regml(0) - $regml(1) - $regml(2) - $regml(3)
Take a good look at both lines. Notice any difference? The second way, $regml(0) returns 3, not 2, and $regml(2) is empty. Isn't that exactly what you wanted?
Regarding the last problem, I don't see how the paragraphs you pasted support your opinion but here's what I found in man.txt:
When any of these functions encounter a substring that is
unset, which can happen when capturing subpattern number n+1
matches some part of the subject, but subpattern n has not
been used at all, they return an empty string. This can be
distinguished from a genuine zero-length substring by
inspecting the appropriate offset in ovector, which is nega-
tive for unset substrings.
So, maybe mirc does something like this, ie deliberately fill $regml(N) only when the offset is NOT negative (which indicates unset substrings). If a positive offset is found, $regml(N) is filled, even if the matched string is zero-length. Anyway, we don't actually know what mirc does internally, but the whole thing certainly does not look like there's a bug. Of course, that's just me.