Posted By

plasticbottle on 03/14/18


Tagged

regex


Versions (?)

PHP regex e-mail validation


 / Published in: PHP
 

It should work for domains like @something.co.uk

note that regex will never really be able to match 100% of e-mail addresses without allowing some false positives

  1. function is_email_valid($email)
  2. {
  3. return (preg_match('/^[a-zA-z0-9._'+][email protected][a-zA-z0-9]+\.([a-z0-9-]{2,4}|[a-z0-9]{2,}+\.[a-z0-9]{2,4})$/', $email) > 0) ? true : false;
  4. }

Report this snippet  

You need to login to post a comment.