Posted By

nebojsac on 06/10/11


Tagged

regex email php validation


Versions (?)

Email Validation PHP Regex


 / Published in: PHP
 

URL: tricksbycinger.blogspot.com

Full email validation with regex.

  1. $regex = "([a-z0-9_.-]+)". # name
  2. "@". # at
  3. "([a-z0-9.-]+){2,255}". # domain & possibly subdomains
  4. ".". # period
  5. "([a-z]+){2,10}"; # domain extension
  6. $eregi = eregi_replace($regex, '', $email);
  7. $valid_email = empty($eregi) ? true : false;

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: webmaker on June 12, 2011

or you could use the built-in php functions : http://php.net/manual/en/filter.examples.validation.php vardump(filtervar('[email protected]', FILTERVALIDATEEMAIL));

Posted By: nebojsac on June 13, 2011

Ah, I totally forgot that exists... Thanks for your comment! I guess I only really need something like this in Javascript form checking.

You need to login to post a comment.