Код для вас:
$pattern = '/((https?|ftp)\:(\/\/)|(file\:\/{2,3}))?(((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|(((([a-zA-Z0-9]+)(\.)?)+)(\.)(com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|[a-z]{2}))([\/][\/a-zA-Z0-9\.]*)*([\/]?(([\?][a-zA-Z0-9]+[\=][a-zA-Z0-9\%\(\)]*)([\&][a-zA-Z0-9]+[\=][a-zA-Z0-9\%\(\)]*)*))?/';
$a = array(
'Lorem ipsum dolor sit amet http://www.google.com/search?q=stackoverflow consectetur adipiscing elit.',
'Phasellus tempor vehicula fringilla. www.google.com/search?q=stackoverflow&ie=utf-8',
'google.com/search?q=stackoverflow&ie=utf-8 Aenean in cursus libero.',
);
$urls = array();
foreach($a as $line)
{
if(!preg_match($pattern, $line, $match))
continue;
$urls[] = $match[0];
}
var_dump($urls);
Регулярное выражение было взято из здесь и немного исправлено.