You are here: Re: eregi expression for checking a domain « PHP « IT news, forums, messages
Re: eregi expression for checking a domain

Posted by Jim Plush on 03/14/05 01:29

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация