note 112812 added to function.preg-match
| From: | JeffWeiss | Date: | Thu, 25 Jul 2013 14:18:30 +0000 |
| Subject: | note 112812 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195771@lists.php.net to get a copy of this message | ||
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
)
----
Server IP: 69.147.83.199
Probable Submitter: 12.165.188.130
----
Manual Page -- http://php.net/manual/en/function.preg-match.php
Edit -- https://master.php.net/note/edit/112812
Del: integrated -- https://master.php.net/note/delete/112812/integrated
Del: useless -- https://master.php.net/note/delete/112812/useless
Del: bad code -- https://master.php.net/note/delete/112812/bad+code
Del: spam -- https://master.php.net/note/delete/112812/spam
Del: non-english -- https://master.php.net/note/delete/112812/non-english
Del: in docs -- https://master.php.net/note/delete/112812/in+docs
Del: other reasons-- https://master.php.net/note/delete/112812
Reject -- https://master.php.net/note/reject/112812
Search -- https://master.php.net/manage/user-notes.php