it can detect 3 part domain name and it wont bother in normal text
PHP Code:
function check_domain($text)
{
$check_domain_in_string = "^([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,5})$";
/*
you can use instead,if you only wanted to detect known domain.
$check_domain_in_string = "^([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.com|edu|co.uk|gov|biz|tv|info|net|co.cc|in$";
*/
if (ereg($check_domain_in_string, $text))
{
return true;
break;
}
return false;
}
Comment