From: ivo_gelov at abv dot bg Operating system: Linux Fedora Core 4 PHP version: 5.2.0 PHP Bug Type: PCRE related Bug description: preg_replace returns NULL if no match, instead of unmodified subject
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 bug report at http://bugs.php.net/?id=39695&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39695&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39695&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39695&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39695&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39695&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39695&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39695&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39695&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39695&r=support Expected behavior: http://bugs.php.net/fix.php?id=39695&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39695&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39695&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39695&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39695&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39695&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39695&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39695&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39695&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39695&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39695&r=mysqlcfg