#42411 [NEW]: ".*" pattern triggers doubled output

From: Date: Fri, 24 Aug 2007 11:54:24 +0000
Subject: #42411 [NEW]: ".*" pattern triggers doubled output
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-116616@lists.php.net to get a copy of this message
From: axelm-php at nona dot net Operating system: Debian/GNU Linux PHP version: 5.2.3 PHP Bug Type: Regexps related Bug description: ".*" pattern triggers doubled output Description: ------------ The function ereg_replace() "duplicates" the replacement string when the match string is ".*". Example: - input "BLABLA" - match ".*" - replace "TEST" Output is "TESTTEST", although it would be expected to be "TEST". Reproduce code: --------------- <? $source = "BLABLA"; $match = ".*"; $replace = "TEST"; print ereg_replace($match, $replace, $source); print "\n"; ?> Expected result: ---------------- only a single "TEST" (as this is the case with sed, too), because i expect ".*" to have maximum greediness. Actual result: -------------- see example code. produces "TESTTEST". This happens in all PHP versions i have access to (older PHP4, current PHP4 and PHP5). Using "^.*" as match, or ".+" works as expected. -- Edit bug report at http://bugs.php.net/?id=42411&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42411&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42411&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42411&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42411&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42411&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42411&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42411&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42411&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42411&r=support Expected behavior: http://bugs.php.net/fix.php?id=42411&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42411&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42411&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42411&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42411&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42411&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42411&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42411&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42411&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42411&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42411&r=mysqlcfg

« previous php.bugs (#116616) next »