Mantis - Quercus
Viewing Issue Advanced Details
4805 minor always 10-13-11 12:26 01-05-13 22:06
lolharuki  
nam  
normal  
closed 4.0.22  
fixed  
none    
none 4.0.34  
0004805: Regex
I'm trying to run the following code:

<?php
     $pattern = '~^(([^:@]*)(:([^@]*))?@)?((?(?=[[])[[][^]]+[]]|[^:]+))(:(.*) )?$~';
     $status = @preg_match($pattern, 'www.google.com', $matches);
 
     echo ($status? 'win' : 'fail');
?>

$ php foo.php
win

But when I request /app/foo.php, it prints 'fail'.
related to 0003879closed nam vBulletin 4.0.1 - invalid conditional regexp 

Notes
(0005708)
nemostein   
03-09-12 14:06   
This pattern should work:
$pattern = '~^(([^:@]*)(:([^@]*))?@)?((?:(?=[[])[[][^]]+[]]|[^:]+))(:(.*) )?$~';

For some reason, PHP accepts hidden groups to be declared like this (? ... ), but Quercus requires a colons (like PCRE specs) after the question mark, like this (?: ... ).
(0006144)
nam   
01-05-13 22:06   
php/4eh[4-b]

Fixed for 4.0.34. Conditionals now work with lookahead/lookbehind assertions.