diff --git a/reference/pcre/pattern.syntax.xml b/reference/pcre/pattern.syntax.xml index f1315e2a0bab..9e832051bc79 100644 --- a/reference/pcre/pattern.syntax.xml +++ b/reference/pcre/pattern.syntax.xml @@ -1510,6 +1510,10 @@ also by name. There are two alternative syntaxes (?<name>pattern) and (?'name'pattern). + + As of PHP 8.4.0, which bundles PCRE2 10.44, the maximum length of a + subpattern name is 128 characters; previously it was 32 characters. + Sometimes it is necessary to have multiple matching, but alternating @@ -1874,37 +1878,24 @@ when the next three characters are "bar". A lookbehind assertion is needed to achieve this effect. - + Lookbehind assertions start with (?<= for positive assertions and (?<! for negative assertions. For example, (?<!foo)bar does find an occurrence of "bar" that is not preceded by - "foo". The contents of a lookbehind assertion are restricted - such that all the strings it matches must have a fixed - length. However, if there are several alternatives, they do - not all have to have the same fixed length. Thus - - (?<=bullock|donkey) - - is permitted, but + "foo". A lookbehind assertion may match strings of variable + length, up to an implementation-defined maximum length. + Alternatives of differing lengths, such as (?<!dogs?|cats?) - causes an error at compile time. Branches that match different - length strings are permitted only at the top level of - a lookbehind assertion. This is an extension compared with - Perl 5.005, which requires all branches to match the same - length of string. An assertion such as + and top-level branches that can match more than one length, such as (?<=ab(c|de)) - is not permitted, because its single top-level branch can - match two different lengths, but it is acceptable if rewritten - to use two top-level branches: - - (?<=abc|abde) + are permitted. The implementation of lookbehind assertions is, for each alternative, to temporarily move the current position back @@ -1914,7 +1905,33 @@ once-only subpatterns can be particularly useful for matching at the ends of strings; an example is given at the end of the section on once-only subpatterns. - + + + Prior to PHP 8.4.0, which bundles PCRE2 10.44, the contents of a lookbehind + assertion were restricted such that all the strings it matched had to have a + fixed length. If there were several alternatives, they did not all have to + have the same fixed length, thus + + (?<=bullock|donkey) + + was permitted, but + + (?<!dogs?|cats?) + + caused an error at compile time. Branches that matched different + length strings were permitted only at the top level of + a lookbehind assertion. This was an extension compared with + Perl 5.005, which required all branches to match the same + length of string. An assertion such as + + (?<=ab(c|de)) + + was not permitted, because its single top-level branch could + match two different lengths, but it was acceptable if rewritten + to use two top-level branches: + + (?<=abc|abde) + Several assertions (of any sort) may occur in succession. For example,