Posted By

leandemon on 03/06/08


Tagged

email php validation validate


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Wiederkehr
dbug13


Validate Email


 / Published in: PHP
 

Completely replaced original regular expression with one that works much better.

  1. function validate_email($email)
  2. {
  3. return preg_match("/^[-_a-z0-9\\'+*\$^&%=~!?{}]++(?:\\.[-_a-z0-9\\'+*\$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\\.[a-z]{2,6}|\\d{1,3}(?:\\.\\d{1,3}){3})(?::\\d++)?\$/iD",$email);
  4. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: koncept on April 14, 2008

.museum is a valid domain. Your regular expression should account for it. e.g. {2,6}

Posted By: leandemon on May 2, 2009

test

Posted By: leandemon on May 2, 2009

Function now supports the .museum domain (and other domains that are 6 letters long)

You need to login to post a comment.