Re: Regular Expressions
| From: | Frank M. Kromann | Date: | Tue, 23 Dec 2003 19:11:58 +0000 |
| Subject: | Re: Regular Expressions | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-22422@lists.php.net to get a copy of this message | ||
Hi,
The replaced string is returned by the function. This works.
$str = "test test2";
$str2 = preg_replace('/ /', ',', $str);
If your are doing simple replacements like this you should use
str_replace() it's much faster!
$str = "test test2";
$str2 = str_replace(' ', ',', $str);
- Frank
> How do I use preg_replace to replace a space (" ") with a comma (",")?
>
> i am using:
>
> preg_replace('/ /', ',', $string).
>
> this isn't working.
>
>
> --
> Gerardo S. Rojas
> mailto: grojas@strategicinc.com
>
>