#37600 [Opn->Bgs]: Strange results with preg_replace using parentheses next to each other

From: Date: Fri, 26 May 2006 11:54:38 +0000
Subject: #37600 [Opn->Bgs]: Strange results with preg_replace using parentheses next to each other
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-97638@lists.php.net to get a copy of this message
ID: 37600 Updated by: tony2001@php.net Reported By: iain at iaindooley dot com -Status: Open +Status: Bogus Bug Type: PCRE related Operating System: FreeBSD 5.4 PHP Version: 5.1.4 New Comment: Please report bugs in PCRELib to PCRE developers (pcre.org). Thanks. Previous Comments: ------------------------------------------------------------------------ [2006-05-26 11:48:27] iain at iaindooley dot com 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 this bug report at http://bugs.php.net/?id=37600&edit=1

« previous php.bugs (#97638) next »