Bug #81537 [Opn->Ver]: Error in regular expression using negation.

From: Date: Mon, 18 Oct 2021 08:43:04 +0000
Subject: Bug #81537 [Opn->Ver]: Error in regular expression using negation.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237255@lists.php.net to get a copy of this message
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:             Open
+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 a PCRE JIT issue (<https://3v4l.org/0Em35> vs.
<https://3v4l.org/I8BQ4>).


Previous Comments:
------------------------------------------------------------------------
[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)

« previous php.bugs (#237255) next »