1.2.1264. Unknown Pcre2 Option¶
PCRE2
supports different options, compared toPCRE1
.PCRE2
was adopted with PHP 7.3.
The S
modifier : it used to tell PCRE to spend more time studying the regex, so as to be faster at execution. This is now the default behavior, and may be dropped from the regex.
The X
modifier : X
is still existing with PCRE2
, though it is now the default for PCRE2
, and not for PHP as time of writing. In particular, Any backslash in a pattern that is followed by a letter that has no special meaning causes an `error <https://www.php.net/error>`_, thus reserving these combinations for future expansion. ``. It is recommended to avoid using useless sequence \s in regex to get ready for that change. All the following letters ``gijkmoqyFIJMOTY
. Note that clLpPuU
are valid PRCE
sequences, and are probably failing for other reasons.
<?php
// \y has no meaning. With X option, this leads to a regex compilation error, and a failed test.
preg_match('/ye\y/', $string);
preg_match('/ye\y/X', $string);
?>
See also Pattern Modifiers and PHP RFC: PCRE2 migration.
1.2.1264.1. Specs¶
Short name |
Php/UnknownPcre2Option |
Rulesets |
|
Exakat since |
1.0.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
Features |
regex |
Available in |