Posted By

aristoworks on 07/01/08


Tagged

email php validation regular expressions address


Versions (?)

Who likes this?

10 people have marked this snippet as a favorite

JimiJay
vince2doom
jdstraughan
DeathfireD
robe
benpjohnson
vali29
symulacra
kitsched
Nikush


PHP (RegEx) Email Address Validation


 / Published in: PHP
 

URL: http://www.thejwalker.com

A simple method of validating an email address using PHP and regular expressions

  1. $string = "[email protected]";
  2. '/^[^\W][a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\@[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/',
  3. $string)) {
  4. echo "example 3 successful.";
  5. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Nikush on October 7, 2010

Very accurate, thanks!

Posted By: blakov on September 10, 2013

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'

Posted By: pego on October 2, 2013

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]"));

You need to login to post a comment.