Bug #81537 [NEW]: Error in regular expression using negation.
From: jansverre at uffe dot no
Operating system: Ubuntu Linux 20.04
PHP version: 8.0.11
Package: PCRE related
Bug Type: Bug
Bug description:Error in regular expression using negation.
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 bug report at https://bugs.php.net/bug.php?id=81537&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81537&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81537&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81537&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81537&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81537&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81537&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81537&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81537&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81537&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81537&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81537&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81537&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81537&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81537&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81537&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81537&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81537&r=mysqlcfg
Thread (8 messages)
- jansverre at uffe dot no