Re: preg_replace newb
| From: | Mohamed Lrhazi | Date: | Mon, 13 Oct 2003 12:17:41 +0000 |
| Subject: | Re: preg_replace newb | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-165966@lists.php.net to get a copy of this message | ||
I would try a petern like this:
$pattern="!<a href='([^>]*)'>([^<]*)</a>!"
check the docs for greedy not greedy thingy...
Mohamed~
On Mon, 2003-10-13 at 06:27, Justin French wrote:
> Hi,
>
> Trying to get this working, without any luck:
>
> $str = preg_replace("!<a
> href='(.*?)'>(.*?)</a>!",'{link|\\2|\\1}',$str);
>
> FWIW, I'm aware that this doesn't ANY WHERE NEAR cover all instances of
> a link, but in this case, I KNOW that the link will have the above
> format, because it was generated by another PHP script I wrote.
>
> Any hints?
>
> Justin