Bug #16537: Bad backslash substitution w/ subexpressions

From: Date: Wed, 10 Apr 2002 20:50:11 +0000
Subject: Bug #16537: Bad backslash substitution w/ subexpressions
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-4557@lists.php.net to get a copy of this message
From: blueroom@digitalmente.net Operating system: Windows (2000) PHP version: 4.1.2 PHP Bug Type: PCRE related Bug description: Bad backslash substitution w/ subexpressions Actually, this is quite simple. Take this: $preg_replace("/.\:\\.*?\\(.*?).gif/i","http://xpto/\\1.img",$string); Theoretically, this would make a simple find-replace, but PHP throws out a "unmatched parenthesis" error (Compilation failed: unmatched parentheses at offset 12 blablabla...). With the only parentheses in that regexp being the "(.*?)" in the middle, the error is awkward. After some juggling I eventually found that it seems that in the "\\(.*?)" part of the expression, the backslash before the parenthesis gets replaced with an actual parenthesis BEFORE the double-backslash is replaced with an actual backslash. I tried putting a space before the parenthesis and no error appeared (obviously, the regexp didn't work like that :). -- Edit bug report at http://bugs.php.net/?id=16537&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=16537&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=16537&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=16537&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=16537&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=16537&r=support Expected behavior: http://bugs.php.net/fix.php?id=16537&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=16537&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=16537&r=submittedtwice

« previous php.bugs (#4557) next »