From: iain at iaindooley dot com Operating system: FreeBSD 5.4 PHP version: 5.1.4 PHP Bug Type: PCRE related Bug description: Strange results with preg_replace using parentheses next to each other
Description: ------------ I can't tell if this is universal, but with this particular regex it certainly is a bug. I think it is to do with using parentheses directly next to each other. Reproduce code: --------------- <? $str = 'arr[sub][sub_sub]'; die(preg_replace('/([^\[\]]*)(.*)/','[\1]\2',$str)); ?> just for the record, this works as expected if i use the pattern: preg_replace('/([^\[\]]*)\[(.*)\]/','[\1][\2]',$el); so it appears that the problem is when parenthesised (is that correct?) expression appear next to each other. Expected result: ---------------- [arr][sub][sub_sub] Actual result: -------------- [arr][sub][sub_sub][] -- Edit bug report at http://bugs.php.net/?id=37600&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37600&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37600&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37600&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37600&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37600&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37600&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37600&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37600&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37600&r=support Expected behavior: http://bugs.php.net/fix.php?id=37600&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37600&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37600&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37600&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37600&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37600&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37600&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37600&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37600&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37600&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37600&r=mysqlcfg