Re: Regular expressions
| From: | Richard Lynch | Date: | Tue, 31 Jul 2001 09:37:34 +0000 |
| Subject: | Re: Regular expressions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-60367@lists.php.net to get a copy of this message | ||
Your three str_replace calls might be faster anyway...
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
----- Original Message -----
From: Philip Murray <me@philth.net.nz>
Newsgroups: php.general
To: PHP General List <php-general@lists.php.net>
Sent: Wednesday, July 18, 2001 12:31 AM
Subject: Regular expressions
> In Perl you can do this:
>
> $foo =~ tr/012/mpf/;
>
> Which is the same as:
>
> $foo = str_replace("0", "m", $foo);
> $foo = str_replace("1", "p", $foo);
> $foo = str_replace("2", "f", $foo);
>
> in PHP.
>
> Is there a more elegant way of doing this in PHP? I tried preg_replace but
> it didn't seem to like my regexp.
>
> Any ideas?
>
> -------------------------------- - -- - - -
> Philip Murray
> me@philth.net.nz
> ------------- - -- - -
>