note 112812 deleted from function.preg-match by peehaa
| From: | peehaa@php.net | Date: | Thu, 09 Mar 2017 09:16:54 +0000 |
| Subject: | note 112812 deleted from function.preg-match by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208884@lists.php.net to get a copy of this message | ||
Note Submitter: Jeff Weiss
----
Example of validating an email address and breaking it into 3 parts ( local, domain name, domain
suffix )
A case insensitive email is valid if:
1) local matches letters a..z or characters . - _ +
2) domain name matches letters a..z or characters - _
3) domain suffix matches letters a..z and is between 2 and 4 characters in length
<?php
preg_match('/(^[a-zA-Z_.+-]+)@([a-zA-Z_-]+).([a-zA-Z]{2,4}$)/i',
"jeff@nowhere.com", $matches);
var_export($matches);
?>
outputs:
Array
(
[0] => jeff@nowhere.com
[1] => jeff
[2] => nowhere
[3] => com
)