Re: Re: problem with ereg() and ereg_replace()
| From: | Alex Shi | Date: | Sun, 02 Sep 2001 04:57:00 +0000 |
| Subject: | Re: Re: problem with ereg() and ereg_replace() | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-65945@lists.php.net to get a copy of this message | ||
Yes, you are right, when add backslashes it works. But I really
don't understand why ereg()/ereg_replace behaves differently on
different servers...
Alex
----- Original Message -----
From: "CC Zona" <cczona@nospam.invalid>
To: <php-general@lists.php.net>
Sent: Saturday, September 01, 2001 11:59 PM
Subject: [PHP] Re: problem with ereg() and ereg_replace()
> In article <01b201c13354$0ca601c0$0105050a@pony>,
> stonix@stonix.com (Stonix) wrote:
>
> > ereg_replace( "{key}", "word", $a_string);
> >
> > The web server will return following warnning msg:
> >
> > Warning: Invalid content of \{\} in /var/www/html/scrip.php on line #
>
> In regex, the curly braces are special characters used to define the
number
> of repetitions to be matched, either as an exact number or as a range.
>
> "a{2}" #"aa"
> "abc(2,3}" #"abcabc" or "abcabcabc"
> "abc{,2}" #"","abc", or "abcabc"
>
> Are you trying to match the literal string "{key}"? 'Cuz if so, you might
> as well just use str_replace since you're not really in need of ereg_*'s
> special pattern matching. If you're trying to match a special character
> with a regex, don't forget to either escape it or put it in a character
> class:
>
> ereg_replace( "\{key\}", "word", $a_string);
> ereg_replace( "[{]key[}]", "word", $a_string);
>
> --
> CC
>
> --
> 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
>
>