ID: 38368 Updated by: [EMAIL PROTECTED] Reported By: bloudon at townnews dot com -Status: Open +Status: Assigned Bug Type: PCRE related Operating System: Slackware Linux 10 PHP Version: 5CVS-2006-08-07 (snap) -Assigned To: +Assigned To: andrei
Previous Comments: ------------------------------------------------------------------------ [2006-08-07 15:02:54] bloudon at townnews dot com Description: ------------ When using preg_replace with a pattern of '/(.*)/' or similar, the returned string will contain two instances of the replacement text, with the second instance appended to the first and given empty backreferences. This behavior does not occur when the pattern is anchored to the start of the string: '/^(.*)/'. ./configure --with-apxs --enable-versioning --enable-memory-limit --with-mysql=/usr --enable-xslt --with-xslt-sablot --with-gd --with-jpeg-dir=/usr --with-zlib-dir=/usr --with-ttf=/usr --with-freetype-dir=/usr --enable-gd-native-ttf --enable-bcmath --with-mime-magic Reproduce code: --------------- <?php echo preg_replace('/(.*)/', 'a$1b', 'foo') ."\n"; echo preg_replace('/(.*)$/', 'a$1b', 'foo') ."\n"; echo preg_replace('/^(.*)/', 'a$1b', 'foo') ."\n"; echo preg_replace('/^(.*)$/', 'a$1b', 'foo') ."\n"; echo preg_replace('/.*/', 'ab', 'foo') ."\n"; echo preg_replace('/f*/', 'ab', 'foo') ."\n"; ?> Expected result: ---------------- afoob afoob afoob afoob ab aboo Actual result: -------------- afoobab afoobab afoob afoob abab ababoaboab ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38368&edit=1