Re: preg_replace newb

From: Date: Mon, 13 Oct 2003 13:37:07 +0000
Subject: Re: preg_replace newb
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-165979@lists.php.net to get a copy of this message
On Mon, Oct 13, 2003 at 11:00:36PM +1000, Justin French wrote: : : On Monday, October 13, 2003, at 10:17 PM, Mohamed Lrhazi wrote: : : >I would try a petern like this: : > : >$pattern="!<a href='([^>]*)'>([^<]*)</a>!" : > : >check the docs for greedy not greedy thingy... : : Mohamed, : : I still can't seem to get it working: : : <? : $str = "<a href='somewhere/else.html'>foo</a>"; : $str = preg_replace("!<a href='([^>]*)'>([^<]*)</a>!",'blah',$str); : echo $str; : ?> : : echo's '<a href='somewhere/else.html'>foo</a>' rather than 'blah' Justin, Your code snippet works for me. My output says "blah". :-)

« previous php.general (#165979) next »