Bug #81537 [Ver]: Error in regular expression using negation.
Edit report at https://bugs.php.net/bug.php?id=81537&edit=1
ID: 81537
Updated by: cmb@php.net
Reported by: jansverre at uffe dot no
Summary: Error in regular expression using negation.
Status: Verified
Type: Bug
Package: PCRE related
Operating System: Ubuntu Linux 20.04
PHP Version: 8.0.11
Block user comment: N
Private report: N
New Comment:
This is apparently fixed in PCRE2 10.39 (or maybe earlier),
bundled as of PHP 8.1.1. I'm not sure whether we should update
PHP-8.0 to this PCRE2 version.
Previous Comments:
------------------------------------------------------------------------
[2021-10-18 08:43:04] cmb@php.net
This is a PCRE JIT issue (<https://3v4l.org/0Em35> vs.
<https://3v4l.org/I8BQ4>).
------------------------------------------------------------------------
[2021-10-18 08:32:32] jansverre at uffe dot no
Description:
------------
Regular expression that *should* match a text does not match it. In the code sample, the second
preg_match will match the link in the string, but not the first, and the only difference is that the
input string contains an extra 'a' letter.
Test script:
---------------
$regex = '/(^|[\n\s\>\\";]+)([^ \,"\t\n\r<>;]+\.[^
\,\"\t\n\r<]+)/iu';
$text = 'This is a normal text. http://vg.no, VG';
preg_match_all($regex, $text, $matches);
print_r($matches);
$text = 'This is normal text. http://vg.no, VG';
preg_match_all($regex, $text, $matches);
print_r($matches);
Expected result:
----------------
Both $matches should contain the link http://vg.no
Actual result:
--------------
Only the last $matches contains the link.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81537&edit=1
Thread (8 messages)