this should work for any web address starting with www.
// test for domain
$domain = "www.example.com";
// This pattern will match anything that STARTS with www followed by a period, followed by at least 2 characters,
// numbers and periods followed by a period followed by at least two characters
$pattern = "#^www\.([a-zA-Z0-9.-]{2,}\.[a-zA-Z]{2,})$#";
if(preg_match($pattern, $domain, $matches)) { echo 'Matched. Domain is: '.$matches[1]; } else { echo 'NO MATCHY DUDE'; }
Ross Hulford wrote:
Does anyone know a working eregi expression for determining a domain is valid? don't need the http:// just looking for www.thedomain.com
cheers,
R.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php