Author: ND Date: To: Pcre-dev Subject: Re: [pcre-dev] Incompatibility with different names for subpatterns
of the same number
On 2018-07-22 15:09, ph10 wrote: >Consider /(?| (?<A>foo) | (?<B>bar) )/x
>The table will tell you "group 1 is called A" and "group 1 is called B".
> What happens if you match the pattern with "foo" and then ask "what is
> the value of group B?". The table will tell you that group B is group 1,
> and group 1 has matched "foo". But this is not right.
No. This is right as we purposefully use "(?|". When we write "(?|" we say:
I don't want a normal capture alias numbering. I want to <A> и <B> have
exactly one number.
If we want to differntiate <A> and <B> then we will don't use "(?|".
This is analogous to
where we say:
I don't want a normal capture numbering. I want to <1> и <2> have exactly
And there are no surprises with this. As long as PCRE don't consider as
when it don't match against "barbar"
I think Perl authors thought about the same.
This message was posted to the following mailing lists: