Re: Regular Expression
| From: | Kelly Hallman | Date: | Sat, 27 Dec 2003 19:27:49 +0000 |
| Subject: | Re: Regular Expression | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-173382@lists.php.net to get a copy of this message | ||
On Sat, 27 Dec 2003, Joshua wrote:
> I'm trying to change the string, for example,
>
> $string = "11.abcd.32.efgh.53.ijk";
> to
>
> 11.abcd.
> 32.efgh.
> 53.ijk.
>
> with ereg_replace. Like
> ereg_replace("\.[0-9]","<BR>",$string);
> How can I recover the original characters after replacing them with <BR>
> in ereg_replace?
>
> ereg_replace("\.[0-9]","<BR>\\0",$string) gives me the
> wrong result like:
>
> 11.abcd.
> 32.efgh.
> 53.ijk.
Since the output you want and the output you didn't want are identical in
your post, it was hard to tell what you were trying to do, but...
I think this is what you want..
ereg_replace("(\.)([0-9])","\\1<br>\\2",$string);
(minus the last decimal point, missing from your original string)
--
Kelly Hallman
// Ultrafancy