Skip to content

[PHP 8.4] PCRE - PCRE2-v10.44 updates #4078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions reference/pcre/pattern.modifiers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,22 @@
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis>r</emphasis> (<literal>PCRE2_EXTRA_CASELESS_RESTRICT</literal>)</term>
<listitem>
<simpara>
When <emphasis>u</emphasis> (<literal>PCRE_UTF8</literal>) and <emphasis>i</emphasis> (<literal>PCRE_CASELESS</literal>)
are in effect, this modifier prevents matching across ASCII and non-ASCII characters.
</simpara>
<simpara>
For example, <code>preg_match('/\x{212A}/iu', "K")</code> matches the Kelvin sign <literal>K</literal> (U+212A).
When <emphasis>u</emphasis> is used (<code>preg_match('/\x{212A}/iur', "K")</code>), it does not match.
</simpara>
<simpara>
Available as of PHP 8.4.0.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</blockquote>
</para>
Expand Down
19 changes: 15 additions & 4 deletions reference/pcre/pattern.syntax.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1573,12 +1573,23 @@

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

matches exactly 8 digits. An opening curly bracket that
matches exactly 8 digits.

</para>
<simpara>
Prior to PHP 8.4.0, an opening curly bracket that
appears in a position where a quantifier is not allowed, or
one that does not match the syntax of a quantifier, is taken
as a literal character. For example, {,6} is not a quantifier,
but a literal string of four characters.
</para>
as a literal character. For example, <literal>{,6}</literal>
is not a quantifier, but a literal string of four characters.

As of PHP 8.4.0, the PCRE extension is bundled with PCRE2 version 10.44,
which allows patterns such as <literal>\d{,8}</literal> and they are
interpreted as <literal>\d{0,8}</literal>.

Further, as of PHP 8.4.0, space characters around quantifiers such as
<literal>\d{0 , 8}</literal> and <literal>\d{ 0 , 8 }</literal> are allowed.
</simpara>
<para>
The quantifier {0} is permitted, causing the expression to
behave as if the previous item and the quantifier were not
Expand Down