Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2000071

Re: [PHP] ereg_replace() From: Andreas Pour (pour <email protected>)
Date: 07/08/00

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):

  $version = ereg_replace("\\\$", "", '$Revision: 1.8 $');

or use single quotes:

  $version = ereg_replace('\$', "", '$Revision: 1.8 $');

Ciao,

Andreas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>