From: xxorax at gmail dot com
Operating system: win32 & debian
PHP version: 5.2.6
PHP Bug Type: PCRE related
Bug description: preg_replace_callback : named subpattern not implemented
Description:
------------
named subpattern is not passed with their names in the array of the
callback function in preg_replace_callback.
this is the same bug of Bug #37911 (1 year) but it is not fixed !
thanks
Reproduce code:
---------------
$regex = '#(?P<int>\d+):(?P<text>\w+)#';
$data = <<<TEST
zedz:fzef
234:zefrfr
13232erf:erfrfe
345345:rgrtgtr
TEST;
function func ($m) {
print_r($m);
return "match";
}
echo $data."\n";
echo preg_replace_callback($regex, 'func', $data);
Expected result:
----------------
zedz:fzef
234:zefrfr
13232erf:erfrfe
345345:rgrtgtr
Array
(
[0] => 234:zefrfr
[int] => 234
[text] => zefrfr
)
Array
(
[0] => 345345:rgrtgtr
[int] => 345345
[text] => rgrtgtr
)
zedz:fzef
match
13232erf:erfrfe
match
Actual result:
--------------
zedz:fzef
234:zefrfr
13232erf:erfrfe
345345:rgrtgtr
Array
(
[0] => 234:zefrfr
[1] => 234
[2] => zefrfr
)
Array
(
[0] => 345345:rgrtgtr
[1] => 345345
[2] => rgrtgtr
)
zedz:fzef
match
13232erf:erfrfe
match
--
Edit bug report at http://bugs.php.net/?id=45748&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=45748&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=45748&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=45748&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45748&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=45748&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45748&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45748&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45748&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45748&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45748&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=45748&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=45748&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45748&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45748&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45748&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45748&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45748&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45748&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45748&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45748&r=mysqlcfg