|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-09-12 20:01 UTC] andrew at linuxjedi dot co dot uk
[2008-09-12 20:09 UTC] scottmac@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 02:00:02 2025 UTC |
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" }