RE: Extract url from string [SOLVED]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/12/07, Brad Fuller <bfuller@xxxxxxxxxxxxxxxx> 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux