|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-11-16 18:14 UTC] nlopess@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Feb 05 04:00:01 2026 UTC |
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