Re: Perl regular expression bug

From: Date: Wed, 17 Jan 2001 18:19:10 +0000
Subject: Re: Perl regular expression bug
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-35095@lists.php.net to get a copy of this message
It's a bug. Try the latest CVS, it has been fixed. Shaun Thomas wrote: > > 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? > > -- > +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+ > | Shaun M. Thomas INN Database Programmer | > | Phone: (309) 743-0812 Fax : (309) 743-0830 | > | Email: sthomas@townnews.com AIM : trifthen | > | Web : hamster.lee.net | > | | > | "Most of our lives are about proving something, either to | > | "ourselves or to someone else." | > | -- Anonymous | > +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- Monte Ohrt <monte@ispi.net> http://www.ispi.net/

« previous php.general (#35095) next »