Re: php and replace vs. perl $data=~ s/<BR>\n//;
| From: | Jani Ollikainen | Date: | Mon, 19 Jun 2000 13:54:04 +0000 |
| Subject: | Re: php and replace vs. perl $data=~ s/<BR>\n//; | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-21733@lists.php.net to get a copy of this message | ||
On Mon, Jun 19, 2000 at 08:15:03AM -0500, Andrei Zmievski wrote:
> Yes, by non-greedy I meant preg_replace() that doesn't process all the
> instances of regexp matches it finds - only some of them.
Yes, so then you can do something like?:
shell: $ echo sdasdasdasd2|perl -pe "s/a{1}//;"
php: $data=preg_replace("/a{1}/","","dsasdasdasd2");
(um, that works already.. why didn't i test it..:)
but, i think that's still too complicated way to replace just the first
match. so i think you could think of making some modifier to preg_replace()
like /f or something.. only first match is replaced, when you don't break
the old behaviour and get that to be more easier. but something like
str_freplace() could be nice also.
but this is just my opinion. you do what you see is best solution:)
--
-----------------------------------------
bestis bestis@iname.com
Jani Ollikainen http://come.to/bestis
-----------------------------------------