Re: [PHP4BETA] bug with preg_replace

From: Date: Fri, 19 Nov 1999 22:27:53 +0000
Subject: Re: [PHP4BETA] bug with preg_replace
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-6534@lists.php.net to get a copy of this message
On Fri, 19 Nov 1999, Florent Maffet wrote: > Hi, > > I am using the function preg_replace with the commands > i and e (for case insensitive and execute). > That function used to work fine with PHP4b2, but it seems > that it does not work anymore (in fact it has a weird > behavior) with PHP4b3 (every RCx and also the release version) > > What is done in my code is sthg like: > > preg_replace("/.*\"(.*)\".*/ie","function(\"\\1\");",$string); > > Note that it DOES work fine in PHP4b2 > And it works for the first occurence of the regexp in string, > but not for the following ones There are two problems at hand here, unrelated. The first one is that your regular expression is not written correctly for your purposes. It will only work on the last occurrence since you have .* before and after the capturing subpattern and it eats everything but what's captured. The correct expression should be "\"(.*?)\"" I believe. But, this has led me to discovering a bug in the eval code which would result in a parse error for anything but the first occurrence. It has been fixed. -Andrei * George Orwell was an optimist. *

« previous php.version4 (#6534) next »