Autor: ph10 Data: A: ND CC: Pcre-dev Assumpte: Re: [pcre-dev] Incompatibility with different names for subpatterns
of the same number
On Wed, 18 Jul 2018, ND via Pcre-dev wrote:
> Docs say:
> "Warning: You cannot use different names to distinguish between two
> subpatterns with the same number because PCRE2 uses only the numbers when
> matching. For this reason, an error is given at compile time if different
> names are given to subpatterns with the same number."
>
>
> But why such constraint exists in PCRE? I see no real reason to generate
> error.
The reason is as it says: PCRE uses only numbers when matching. This is
because names were added as a later feature (before Perl had them, and
also before Perl introduced (?| which allows several groups with the
same number). The feature was added by creating a table that translates
a group number to a group name. This means that for each number, there
must only be one name.