/ Published in: PHP

URL: http://www.thejwalker.com
A simple method of validating an email address using PHP and regular expressions
Expand |
Embed | Plain Text
'/^[^\W][a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\@[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/', $string)) { echo "example 3 successful."; }
Comments

You need to login to post a comment.
Very accurate, thanks!
What you think about this short form?
'/^[^\W][a-z0-9]+(.[a-z0-9]+)\@[a-z0-9]+(.[a-z0-9]+).[a-z]{2,4}$/i'
It's wrong!
TRY: vardump(pregmatch('/^[^\W][a-zA-Z0-9]+(.[a-zA-Z0-9]+)\@[a-zA-Z0-9]+(.[a-zA-Z0-9]+).[a-zA-Z]{2,4}$/', "[email protected]"));