Edit report at http://bugs.php.net/bug.php?id=53855&edit=1

 ID:                 53855
 Updated by:         [email protected]
 Reported by:        richard at roguewavelimited dot com
 Summary:            preg_replace doing double replacement
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Regexps related
 Operating System:   Mac OSX 10.6.6
 PHP Version:        5.3.3
 Block user comment: N
 Private report:     N

 New Comment:

This is expected behaviour and nothing peculiar to PHP.  The *
quantifier allows 

an "empty" match to occur at the end of your subject string.


Previous Comments:
------------------------------------------------------------------------
[2011-01-27 15:00:03] richard at roguewavelimited dot com

Correct php version

------------------------------------------------------------------------
[2011-01-27 14:58:49] richard at roguewavelimited dot com

Description:
------------
The preg_replace is doing a double replacement when the parenthesized
pattern is the whole string.

Test script:
---------------
define ('EOL', "\n");



$patterns = '|(.*)|';

$replacements = '$1-new';

$line = 'OLD';



$line = @preg_replace($patterns, $replacements, $line, -1, $changes);

print $line . EOL;

Expected result:
----------------
'OLD-new'





Actual result:
--------------
'OLD-new-new'


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53855&edit=1

Reply via email to