ID:               46068
 Updated by:       [EMAIL PROTECTED]
 Reported By:      sv4php at fmethod dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         PCRE related
 Operating System: Windows, Linux
 PHP Version:      5.2.6
 New Comment:

I can reproduce this with PCRE 7.8, you need to report this upstream to
them.

http://bugs.exim.org/enter_bug.cgi?product=PCRE


Previous Comments:
------------------------------------------------------------------------

[2008-09-12 20:01:44] andrew at linuxjedi dot co dot uk

Tried in PHP 5.2.4, also tried the (?P<name>pattern) method, same
problem.

------------------------------------------------------------------------

[2008-09-12 19:54:10] sv4php at fmethod dot com

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 this bug report at http://bugs.php.net/?id=46068&edit=1

Reply via email to