Autor: Ahmad Amireh Data: Dla: pcre-dev Temat: [pcre-dev] Capturing duplicate named subpatterns in conditional
branches always refers to the last
Hi,
I'm having trouble figuring out how to capture duplicate named
subpatterns (as allowed by the PCRE_DUPNAMES option). My initial
understanding from reading the manual was that I could refer to a
subpattern(s) capture using a name instead of the capture order number.
While that is true, it seems the named subpattern capture always refers
to the _last_ branch in which it was _defined_ and not necessarily
matched. The example in the manual is almost exactly like what I'm
trying to do so I'll just use it to explain:
Since only _one_ (or none) of these branches would be captured, I expect
<DN> to contain the capture from _that_ branch and not the last. Right
now it returns false for all subject except for "Saturday". Did I
misunderstand the usage of the PCRE_DUPNAMES option or is this a bug?
PS: I've tried using the branch resetting feature ( (?|) ) and it does
indeed solve the above but it doesn't satisfy my requirements since it
enforces the subpatterns to be identically named (by order).