You can directly validate url using filter_var
and FILTER_VALIDATE_URL
if (filter_var($url, FILTER_VALIDATE_URL) !== false)
Edit
With Regex
$subject = "http://www.google.com";
$pattern = "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i";
preg_match($pattern, $subject, $matches);
print_r($matches);
Output
Array ( [0] => http://www.google.com )
Codepad