ID: 39695 User updated by: ivo_gelov at abv dot bg Reported By: ivo_gelov at abv dot bg -Status: Feedback +Status: Open Bug Type: PCRE related Operating System: Linux Fedora Core 4 PHP Version: 5.2.0 New Comment:
I checked "$2$1" instead of "\$2\$1" and it worked. So this is my fault since I was looking an example in an old manual, not the current one. Sorry for disturbing. But there is another issue - when I used preg_replace in PHP 5.1.4 with a relatively long string as a subject, it worked without problems. But after upgrade to 5.2.0, it now gives me an error PREG_BACKTRACK_LIMIT_ERROR with default value for "pcre.backtrack_limit" (not listed in PHP.INI at all). What can I do ? Should I revert back to 5.1.4 ? Or just compile 5.2.0 with the 6.6 version of PCRE library ? Previous Comments: ------------------------------------------------------------------------ [2006-11-30 17:36:52] [EMAIL PROTECTED] Not reproducible. Btw, this code - $rep = '\$2\$1'; apparently won't work. ------------------------------------------------------------------------ [2006-11-30 16:55:02] ivo_gelov at abv dot bg Description: ------------ There are 2 strange effects/bugs, may be one depends on the other, I do not know. 1. PREG_REPLACE does not recognize $n as a back reference in its second argument. It will recognize only \\n references. 2. PREG_REPLACE returns NULL if no match is found, instead of returning unmodified subject This symptom is present only in 5.2.0 - there are no problems with 5.1.0 Reproduce code: --------------- $pat = '/^([a-zA-Z])(\d*)$/'; $rep = '\$2\$1'; $b = preg_replace($pat,$rep,'D764209812'); Expected result: ---------------- $b should be '764209812D' Actual result: -------------- $b is NULL ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39695&edit=1