Possible Duplicate:
PHP validation/regex for URL
I'm building a small app in PHP, and have to validate domain names (for use in E-mail addresses). For instance if I have mads@gmail.com I want to check if gmail.com is a valid domain name (I'm essentially throwing away the part before the @).
I have been using the following code:
if (!preg_match ("/^[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/i", trim($valid_emails[$i]))) {
// Return error
}
And everything has been working fine. Until I got GE MoneyBank as a client. They are using ge.com as their domain, and that doesn't pass.
I have a rudimentary understanding of regex, and have tried deleting some of the [a-z0-9] blocks so the minimum character count comes down to 2, but without luck. Can anyone with more experience point me in the right direction?
Thanks in advance