Re: eregi expression for checking a domain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux