Skip to content

Instantly share code, notes, and snippets.

@pmcalabrese
Created September 8, 2016 09:50
Show Gist options
  • Save pmcalabrese/d2d44d5f2c983c9b8ca326b8c0830fb7 to your computer and use it in GitHub Desktop.
Save pmcalabrese/d2d44d5f2c983c9b8ca326b8c0830fb7 to your computer and use it in GitHub Desktop.
Python email validation
import re
def is_email_valid(email):
email_regex = ('^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@('
'[a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|c'
'oop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mo'
'bi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{'
'1,3}))(:[0-9]{1,5})?$')
return re.match(email_regex, email, re.IGNORECASE) is not None
r = is_email_valid('Marco@gmail.com')
print(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment