From:             
Operating system: Mac OSX 10.6.6
PHP version:      5.3.5
Package:          Regexps related
Bug Type:         Bug
Bug description:preg_replace doing double replacement

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 bug report at http://bugs.php.net/bug.php?id=53855&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=53855&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=53855&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=53855&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=53855&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53855&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=53855&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=53855&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=53855&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=53855&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=53855&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=53855&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=53855&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=53855&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=53855&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53855&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53855&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=53855&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=53855&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=53855&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=53855&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=53855&r=mysqlcfg

Reply via email to