Bug #10668 Updated: preg_replace backquote failure
| From: | andrei@php.net | Date: | Fri, 04 May 2001 16:58:49 +0000 |
| Subject: | Bug #10668 Updated: preg_replace backquote failure | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-53877@lists.php.net to get a copy of this message | ||
ID: 10668
Updated by: andrei
Reported By: smoonen@andstuff.org
Old-Status: Open
Status: Analyzed
Bug Type: PCRE related
PHP Version: 4.0.5
Assigned To:
Comments:
Can you explain why you think it fails? The following sample (slightly modified from yours to dump
the $s parameter to function):
$str = "abc'\\\\''def";
function f($s) { var_dump($s); return "x"; }
print preg_replace("/c(.*)d/e", "f('\\1')", $str);
outputs:
string(5) "'\\''"
abxef
As it should.
Previous Comments:
---------------------------------------------------------------------------
[2001-05-04 11:44:19] smoonen@andstuff.org
The following code succeeds on PHP 4.03 and PHP 4.04pl1, but fails on PHP 4.05:
$str = "abc'\\''def";
function f($s) { return "x"; }
print preg_replace("/c(.*)d/e", "f('\1')", $str, -1);
This seems to expose *two* underlying bugs:
1) There appears to be some problem in the regex state
machine
2) There is a definite problem with the replacement of
the backreference with its corresponding string.
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=10668&edit=2