Re: preg question
| From: | mark at amtmedia dot com | Date: | Thu, 12 Apr 2001 22:50:11 +0000 |
| Subject: | Re: preg question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-48370@lists.php.net to get a copy of this message | ||
"Michael Geier" <mgeier@cdmsports.com> wrote:
> What I need to find is all the urls in the document and make hrefs out of
> them.
>
> ie:
> http://www.mysite.com becomes <a
>
> href="http://www.mysite.com">http://www.mysite.com</a>
>
> any ideas? TIA!
I use this code in my PHPost project:
$s = ereg_replace("([[:alpha:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])",
"<a href=\"\\1://\\2\\3\"
target=\"_blank\">\\0</a>", $s );
Mark