Autor: ND Data: A: Pcre-dev Assumpte: [pcre-dev] Incompatibility with different names for subpatterns of
the same number
Good day.
I meet incompatibility with Perl when trying to use in PCRE valid Perl
pattern:
PCRE2 version 10.31 2018-02-12
/(?|(?<x>)|(?<y>))/
Failed: error 165 at offset 15: different names for subpatterns of the
same number are not allowed
a
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.
Instead every (?&y) should be translate to (?1), every \k<y> - to \1.