Re: Extract url from string
| From: | Tijnema ! | Date: | Mon, 12 Mar 2007 17:10:07 +0000 |
| Subject: | Re: Extract url from string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-250301@lists.php.net to get a copy of this message | ||
On 3/12/07, Brad Fuller <bfuller@cpacampaigns.com> wrote:
Hey guys, I've been banging my head against the wall trying to figure out the right pattern to use to extract a URL from a string using preg_match(). I've been STFW for a while now, and all the examples that I find are for extracting URLs from within a <a href=""> tag. Here's what I need, and I'm sure it's quite common, especially with forums etc.; hopefully someone has a code snippet they can share. INPUT: This is some text http://www.example.com/page.html this is some more text. OUTPUT: This is some text <a href="http://www.example.com/page.html">http://www.example.com/page.html </a> this is some more text. Thx in advance, -BI'm not very familiar with PCRE, but you should search for a pattern starting with http: and ends with a space. Tijnema --
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php