note 86525 modified in function.preg-match by danbrown
| From: | danbrown@php.net | Date: | Thu, 23 Oct 2008 16:12:59 +0000 |
| Subject: | note 86525 modified in function.preg-match by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145655@lists.php.net to get a copy of this message | ||
If you need to check for .com.br and .com.au and .uk and all the other crazy domain endings i found
the following expression works well if you want to validate an email address. Its quite generous in
what it will allow
<?php
$email_address = "phil.taylor@a_domain.tv";
if (preg_match("/^[^@]*@[^@]*\.[^@]*$/", $email_address)) {
return "E-mail address";
}
?>
--was--
If you need to check for .com.br and .com.au and .uk and all the other crazy domain endings i found
the following expression works well if you want to validate an email address. Its quite generous in
what it will allow
<?
$email_address = "phil.taylor@a_domain.tv";
if (preg_match("/^[^@]*@[^@]*\.[^@]*$/", $email_address)) {
return "E-mail address";
}
?>
http://php.net/manual/en/function.preg-match.php