RE: [PHP] Extract url from string [SOLVED]
| From: | Brad Fuller | Date: | Mon, 12 Mar 2007 17:32:06 +0000 |
| Subject: | RE: [PHP] Extract url from string [SOLVED] | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-250305@lists.php.net to get a copy of this message | ||
On 3/12/07, Brad Fuller <bfuller@cpacampaigns.com> wrote:
> I tried this:
>
> preg_match("/http(s)?:\/\/(*.?)\s/", $stringUrl, $matches)
>
> But my pattern syntax is messed up cuz I get this error:
>
> Warning: preg_match() [function.preg-match]: Compilation failed:
> nothing to repeat at offset 15 in /path/to/myfile.php on line 5
>
OK - I must not have had enough caffeine today. It's (.*?) not (*.?)
I figured it out.
echo preg_replace("/http(s)?:\/\/(.*?)\s/i", "<a
href=\"$0\">$0</a>",
$stringUrl);
Thx,
-B