Defining Subpatterns for use by reference.
The maximum number of capturing Subpatterns is 65535.
Assertion Subpatterns are not capturing Subpatterns.
Consider the same regular expression, but with the Subpattern explicitly named'FOO':.
To help with this difficulty, PCRE supports the naming of Subpatterns.
Now consider the same regular expression, but with the Subpattern explicitly named'FOO':.
In PCRE, a Subpattern can be named in one of three ways:(? …)?
Atomic groups in general can contain any complicated Subpatterns, and can be nested.
If there is no such group within the Subpattern,(*THEN) causes the subroutine match to fail.
But as the Subpattern is named, we
can also give its name in the value list::.
But, as the Subpattern is named, we
can also specify its name in the value list:.
If there is more than one Subpattern with the same name, the earliest one is used.
A Subpattern that is referenced by name can appear in the pattern before
or after the reference.
A Subpattern that is referenced by name may appear in the pattern before
or after the reference.
Each of the two alternatives can itself contain nested Subpatterns of any form, including conditional Subpatterns;
If a Subpattern has not been used in a particular match,
any back references to it always fails.
However, when it is inside a Subpattern that is called as a subroutine,
only that Subpattern is ended successfully.
(An alternative way of
solving this problem is to use a"branch reset" Subpattern, as described in the previous section.).
The condition is true if the most recent recursion is into a Subpattern whose number or name is given.
The condition is true if the most recent recursion is into the Subpattern whose number or name is given.
The numbers of any capturing parentheses that follow the Subpattern start after the highest number used in any branch.
In general, Subpatterns that got assigned no value in the match are
returned as the tuple{-1,0} when type is index.
If the condition is the string(DEFINE), and there is no Subpattern with the name DEFINE, the condition is always false.
For this reason, an error is given at compile
time if different names are specified to Subpatterns with the same number.
(Duplicate names are also always permitted for Subpatterns with the same number, set up as described in the previous section.).
If the alternatives are within a Subpattern(defined in section Subpatterns),"succeeds" means matching
the remaining main pattern and the alternative in the Subpattern.
You cannot use different names to distinguish between two Subpatterns with the same number because PCRE uses only
the numbers when matching.
You cannot use different names to distinguish between two Subpatterns with the same number, as
PCRE uses only the numbers when matching.
If the alternatives are within a Subpattern(defined below),"succeeds" means matching the rest of the main
pattern as well as the alternative in the Subpattern.
The sequence\g{-1} is a reference to the most recently started capturing Subpattern before\g, that is, it is equivalent to \2 in this example.