ID: 32068 Updated by: [EMAIL PROTECTED] Reported By: simon at ruderich dot com -Status: Open +Status: Bogus Bug Type: Output Control Operating System: Mac OS X 10.3.8 PHP Version: 4.3.10 New Comment:
This line: #$pattern = '#\( (( (?>[^()]+) | (?R) )*) \)#isUx'; has a ?> in it, which marks the end of a script block. No bug here (this is also documented in the manual) Previous Comments: ------------------------------------------------------------------------ [2005-02-22 22:56:29] simon at ruderich dot com Description: ------------ I wanted to replace a string using the 'preg_replace'- function. I tried more patterns, so I commented out the old patterns. But then it showed me not the replace string. This must be a problem with the perl comment (#) because if I use /* */ to comment out the old pattern the script works. Reproduce code: --------------- <?php error_reporting(E_ALL); $string = " <a> asdf </a> <a> <a> test </a> <a> test </a> <a> test </a> </a> <a>asdf</a> <a>asdf</a> "; #$pattern = '#<a>( ( ([^<>])|(?R) )*? )</a>#isx'; #$pattern = '#<a>( ( (?R)|() )*? )</a>#isx'; #$pattern = '#\( (( (?>[^()]+) | (?R) )*) \)#isUx'; $pattern = '#<a>( (.)*? )</a>#isxU'; $replace = '[a]$1[/a]'; echo '<pre>'."\n"; echo htmlspecialchars($string); echo "\n\n"; echo htmlspecialchars(preg_replace($pattern, $replace, $string)); echo '</pre>'."\n"; ?> Expected result: ---------------- <a> asdf </a> <a> <a> test </a> <a> test </a> <a> test </a> </a> <a>asdf</a> <a>asdf</ a> [a] asdf </a> <a> <a> test </a> <a> test </a> <a> test </a> </a> <a>asdf</a> <a>asdf[/ a] Actual result: -------------- [^()]+) | (?R) )*) \)#isUx'; $pattern = '#( (.)*? )#isxU'; $replace = '[a]$1[/a]'; echo ' '."\n"; echo htmlspecialchars($string); echo "\n\n"; echo htmlspecialchars(preg_replace($pattern, $replace, $string)); echo ' '."\n"; ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32068&edit=1
