I'd use regex to match URL's, something like,
$regex(str,/((http:\/\/?)(www\.?).*.\.*)/Si)
$regml(1) - URL string