#37911 [Asn->Csd]: preg_replace_callback ignores named groups
| From: | nlopess@php.net | Date: | Sun, 07 Oct 2007 11:52:56 +0000 |
| Subject: | #37911 [Asn->Csd]: preg_replace_callback ignores named groups | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-118275@lists.php.net to get a copy of this message | ||
ID: 37911
Updated by: nlopess@php.net
Reported By: thomas dot kalka at gmail dot com
-Status: Assigned
+Status: Closed
Bug Type: PCRE related
Operating System: xubuntu
PHP Version: 5.1.4
Assigned To: andrei
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2006-06-25 21:22:05] thomas dot kalka at gmail dot com
Description:
------------
unfortunately preg_replace_callback does not handle named groups
Reproduce code:
---------------
<?php
$a = "bla blub blah";
$regex = '|(?P<name>blub)|';
function callback($match) { var_dump($match); return '-'; }
preg_replace_callback($regex,'callback',$a);
$m = array(); preg_match($regex,$a,$m); var_dump($m);
?>
Expected result:
----------------
array(3) {
[0]=>
string(4) "blub"
["name"]=>
string(4) "blub"
[1]=>
string(4) "blub"
}
array(3) {
[0]=>
string(4) "blub"
["name"]=>
string(4) "blub"
[1]=>
string(4) "blub"
}
Actual result:
--------------
array(2) {
[0]=>
string(4) "blub"
[1]=>
string(4) "blub"
}
array(3) {
[0]=>
string(4) "blub"
["name"]=>
string(4) "blub"
[1]=>
string(4) "blub"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37911&edit=1