From: thomas-meyer at uni dot de Operating system: Windows XP PHP version: 4.3.10 PHP Bug Type: PCRE related Bug description: Bug concerning use of preg_replace
Description: ------------ There is a problem with PCRE in both PHP-versions (4.3.10 and 5.0.3) When using preg_replace with: $b = preg_replace("/(some)thing/", "\\1$replace", $a); This works fine, as long as $replace does start with any character that is NOT a number. BUT: if $replace starts with a number (like "1abc") FIRST this string: "\\11abc" will be created. THEN it will try to replace \\11 by the 11th remembered position instead of replacing \\1 with the 1st one. This bug could lead to strange/unexpected results and should be fixed soon. Reproduce code: --------------- <?php $temp = '<input value="test">'; $a = 123; echo "<P>Perl</P>\n"; $temp1 = preg_replace("/(<[^>]*)test([^>]*>)/Usi", "\\1".$a."\\2", $temp); echo $temp1; echo "<P>POSIX</P>\n"; $temp1 = eregi_replace("(<[^>]*)test([^>]*>)", "\\1".$a."\\2", $temp); echo $temp1; ?> Expected result: ---------------- <P>Perl</P> <input value="123"> <P>POSIX</P> <input value="123"> Actual result: -------------- <P>Perl</P> 23"> <P>POSIX</P> <input value="123"> -- Edit bug report at http://bugs.php.net/?id=32404&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32404&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32404&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32404&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=32404&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=32404&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=32404&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=32404&r=needscript Try newer version: http://bugs.php.net/fix.php?id=32404&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=32404&r=support Expected behavior: http://bugs.php.net/fix.php?id=32404&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=32404&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=32404&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=32404&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32404&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=32404&r=dst IIS Stability: http://bugs.php.net/fix.php?id=32404&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=32404&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=32404&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=32404&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=32404&r=mysqlcfg