Re: [Fwd: [PHP] Perl regular expression bug]

From: Date: Tue, 16 Jan 2001 15:24:18 +0000
Subject: Re: [Fwd: [PHP] Perl regular expression bug]
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-34823@lists.php.net to get a copy of this message
> This only applies to PHP 4.0.4 > > Back with PHP 4.0.2, I could do this: > > <?PHP > $string = "[["; > $string = preg_replace("/(\W)/", "\\\\1", $string); > ?> > > $string would then contain "\[\[". > > Now, if I use that same code, $string contains "\\1\\1\\1\\1". > > I tried to compensate for this using PHP's new ability to allow > perl syntax in the replace section. > > <?PHP > $string = "[["; > $string = preg_replace("/(\W)/", "\\$1", $string); > ?> > > That leaves $string with "\$1\$1\$1\$1". Which tells me it thought > I was backreferencing the $. So, to combat said assumption, I tried > three, four, even five slashes in front of $1, and nothing worked. > All I got were variations of "\$1\$1\$1\$1". > > I have to assume this is a bug, since this worked back in 4.0.2 which > I stopped using due to segfaults under certain circumstances. > > Ideas? It is indeed a bug - I fixed it in CVS version if you want to try that. -Andrei * A feature is a bug with seniority. *

« previous php.general (#34823) next »