From: sv4php at fmethod dot com Operating system: Windows, Linux PHP version: 5.2.6 PHP Bug Type: PCRE related Bug description: Incorrently reported PCRE / PREG regex named pattern
Description: ------------ Under certain circumstanced, the $matches in a preg_match contain the wrong name of a named subpattern. Refer to the example below. Note the conditions: 1. The named patterns have the same numeric index (as they are in a switch group: (?| .. | .. | .. ) ). 2. The last name alphabetically is always reported, never mind of the pattern order and the actual pattern matched ('zoo' is last after 'poo', 'hoo' alphabetically in the example below). Reproduced on Linux and Windows. Reproduce code: --------------- $c = 'yo'; $p = '/(?|(?<poo>yo)|(?<hoo>fo)|(?<zoo>ho))/'; preg_match ($p, $c, $m); var_dump($m); Expected result: ---------------- array(3) { [0]=> string(2) "yo" ["poo"]=> <-- notice the name string(2) "yo" [1]=> string(2) "yo" } Actual result: -------------- array(3) { [0]=> string(2) "yo" ["zoo"]=> <-- notice the name string(2) "yo" [1]=> string(2) "yo" } -- Edit bug report at http://bugs.php.net/?id=46068&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46068&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46068&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46068&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46068&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=46068&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46068&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46068&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46068&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46068&r=support Expected behavior: http://bugs.php.net/fix.php?id=46068&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46068&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46068&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46068&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46068&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46068&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46068&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46068&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46068&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46068&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46068&r=mysqlcfg