Re: eregi expression for checking a domain

From: Date: Sun, 13 Mar 2005 23:29:10 +0000
Subject: Re: eregi expression for checking a domain
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-210631@lists.php.net to get a copy of this message
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.


« previous php.general (#210631) next »