Skip to content

Commit c43393d

Browse files
authored
[PHP 8.4] PCRE - PCRE2-v10.44 updates (#4078)
* [PHP 8.4] PCRE: Add `/r` modifier * [PHP 8.4] PCRE: Add PCRE2-v10.44 quantifier changes
1 parent ee8d203 commit c43393d

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

reference/pcre/pattern.modifiers.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,22 @@
187187
</simpara>
188188
</listitem>
189189
</varlistentry>
190+
<varlistentry>
191+
<term><emphasis>r</emphasis> (<literal>PCRE2_EXTRA_CASELESS_RESTRICT</literal>)</term>
192+
<listitem>
193+
<simpara>
194+
When <emphasis>u</emphasis> (<literal>PCRE_UTF8</literal>) and <emphasis>i</emphasis> (<literal>PCRE_CASELESS</literal>)
195+
are in effect, this modifier prevents matching across ASCII and non-ASCII characters.
196+
</simpara>
197+
<simpara>
198+
For example, <code>preg_match('/\x{212A}/iu', "K")</code> matches the Kelvin sign <literal>K</literal> (U+212A).
199+
When <emphasis>u</emphasis> is used (<code>preg_match('/\x{212A}/iur', "K")</code>), it does not match.
200+
</simpara>
201+
<simpara>
202+
Available as of PHP 8.4.0.
203+
</simpara>
204+
</listitem>
205+
</varlistentry>
190206
</variablelist>
191207
</blockquote>
192208
</para>

reference/pcre/pattern.syntax.xml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,12 +1573,23 @@
15731573

15741574
<literal>\d{8}</literal>
15751575

1576-
matches exactly 8 digits. An opening curly bracket that
1576+
matches exactly 8 digits.
1577+
1578+
</para>
1579+
<simpara>
1580+
Prior to PHP 8.4.0, an opening curly bracket that
15771581
appears in a position where a quantifier is not allowed, or
15781582
one that does not match the syntax of a quantifier, is taken
1579-
as a literal character. For example, {,6} is not a quantifier,
1580-
but a literal string of four characters.
1581-
</para>
1583+
as a literal character. For example, <literal>{,6}</literal>
1584+
is not a quantifier, but a literal string of four characters.
1585+
1586+
As of PHP 8.4.0, the PCRE extension is bundled with PCRE2 version 10.44,
1587+
which allows patterns such as <literal>\d{,8}</literal> and they are
1588+
interpreted as <literal>\d{0,8}</literal>.
1589+
1590+
Further, as of PHP 8.4.0, space characters around quantifiers such as
1591+
<literal>\d{0 , 8}</literal> and <literal>\d{ 0 , 8 }</literal> are allowed.
1592+
</simpara>
15821593
<para>
15831594
The quantifier {0} is permitted, causing the expression to
15841595
behave as if the previous item and the quantifier were not

0 commit comments

Comments
 (0)