Skip to content
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

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 14 additions & 3 deletions reference/pcre/pattern.syntax.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1573,11 +1573,22 @@

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

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

</para>
<para>
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.
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.
Comment on lines +1580 to +1591
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly those should be 3 different <simpara> ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, it makes sense that we split them.

<simpara> <para>
image image

I tried with three <simpara> tags, and a separate <para>, I liked the second one because it puts all PHP 8.4 stuff together, and looks more compact. What do you think? I pushed with the <para> tag now, but if you think <simpara> makes more sense, I can quickly change to that too 🙏.

</para>
<para>
The quantifier {0} is permitted, causing the expression to
Expand Down