Posted By


plasticbottle on 03/14/18

Tagged


Statistics


Viewed 1098 times
Favorited by 0 user(s)

PHP regex e-mail validation


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. function is_email_valid($email)
  2. {
  3. return (preg_match('/^[a-zA-z0-9._'+]+@[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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.