Mantis - Quercus
Viewing Issue Advanced Details
2943 minor always 09-16-08 16:37 09-17-08 11:46
koreth  
 
normal  
closed 3.2.1  
fixed  
none    
none 3.2.1  
0002943: preg_replace doesn't deal properly with empty subexpression
<?php
$foo = "12345xy6789";
print preg_replace('/^(|[^x]*x)y.*/', '\1', $foo);

Vanilla PHP prints "12345x". Quercus prints "12345xy6789" -- the empty alternative at the beginning of the subexpression confuses it. If you remove the "|" this test works (but that obviously changes the meaning of the regular expression.)

Notes
(0003451)
ferg   
09-17-08 11:45   
php/4e6b