$text = "мой текст site.com";
preg_match_all('/(https?:\/\/)?([\w\.]+)\.([a-z]{2,6}\.?)(\/[\w\.]*)*\/?/', $text, $a);
print_r($a[0]);
$testLinks = "site.com";
preg_match(' /^(https?:\/\/)?([\w\.]+)\.([a-z]{2,6}\.?)(\/[\w\.]*)*\/?$/', $testLinks, $matches);
$testLinks = "ddd site.com";
preg_match(' /^(https?:\/\/)?([\w\.]+)\.([a-z]{2,6}\.?)(\/[\w\.]*)*\/?$/', $testLinks, $matches);