Re: ereg_replace()

From: Date: Sun, 09 Jul 2000 02:26:00 +0000
Subject: Re: ereg_replace()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5577@lists.php.net to get a copy of this message
Andreas Pour:
Brian Clark wrote:
var $version = ereg_replace("[\$]", "", '$Revision: 1.8 $'); The above $version holds the string Revision: 1.8 var $version = ereg_replace("\$", "", '$Revision: 1.8 $'); The above $version holds nothing. Why does ereg_replace() require [] around the pattern?
It doesn't, but if you use double quotes you need to escape twice (once for the php parser and once to tell ereg its really the dollar sign and not an end-of-line metacharacter):
Say what? That's why I escaped the dollar sign in the first place. Something just seems really screwed about the way that works.. (But I realize now I should be using single quotes anyway.)
$version = ereg_replace("\\\$", "", '$Revision: 1.8 $'); or use single quotes: $version = ereg_replace('\$', "", '$Revision: 1.8 $'); Ciao, Andreas
Thanks Andreas, Brian

« previous php.general (#5577) next »