Re: ereg_replace()
| From: | erythros | Date: | Sun, 16 Nov 2003 04:05:58 +0000 |
| Subject: | Re: ereg_replace() | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-169805@lists.php.net to get a copy of this message | ||
chris and justin, you guys rock. thanx for pointing towards str_replace().
my code works now. thanx!
"Justin French" <justin@indent.com.au> wrote in message
news:EAF30B0E-17E7-11D8-833B-000A9579CE3A@indent.com.au...
> On Sunday, November 16, 2003, at 02:31 PM, erythros wrote:
>
> > ok, so i'm stupid. how do i replace all '? ' with '?? '....
> >
>
> No need for regular expressions here.
>
> <?
> $str = 'well, how do I do this? should i experiment?';
> $newStr = str_replace('? ','?? ',$str);
> echo $newStr;
> // should echo well, how do I do this?? should i experiment?
> ?>
>
> Unless you want ANY white space (\n, \t, etc) instead of just spaces,
> an ereg would be better. I prefer preg_replace():
>
> <?
> $str = 'well, how do I do this? should i experiment?';
> $newStr = str_replace('/?(\s)/','??\\1',$str);
> echo $newStr;
> ?>
>
>
> Justin French