From: Arne dot Heizmann at csr dot com Operating system: All PHP version: 5.2.6 PHP Bug Type: Regexps related Bug description: preg_match_all() misses elements (corner-case)
Description: ------------ The following example code demonstrates that preg_match_all() does not always return all elements as it should. Almost any change to the input string makes the bug no longer trigger. For example, remove one of the B's, and the bug no longer occurs. Same goes for the regexp: if you change the (?=X|Y) to (?=X) or anything simpler, the bug no longer triggers. Reproduce code: --------------- <? header ('Content-type: text/plain'); $input = 'A, BBBBBBBB abcd abcd\'y'; preg_match_all ("/[AB]+(?:\\s*\\w+)*(?=X|Y)|./si", $input, $output); var_export ($output); ?> Expected result: ---------------- array ( 0 => array ( 0 => 'A', 1 => ',', 2 => ' ', 3 => 'B', 4 => 'B', 5 => 'B', 6 => 'B', 7 => 'B', 8 => 'B', 9 => 'B', 10 => 'B', 11 => ' ', 12 => 'a', 13 => 'b', 14 => 'c', 15 => 'd', 16 => ' ', 17 => 'a', 18 => 'b', 19 => 'c', 20 => 'd', 21 => '\'', 22 => 'y', ), ) Actual result: -------------- array ( 0 => array ( 0 => 'A', 1 => ',', 2 => ' ', ), ) -- Edit bug report at http://bugs.php.net/?id=45366&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45366&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45366&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45366&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45366&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45366&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45366&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45366&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45366&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45366&r=support Expected behavior: http://bugs.php.net/fix.php?id=45366&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45366&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45366&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45366&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45366&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45366&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45366&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45366&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45366&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45366&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45366&r=mysqlcfg