Created
September 8, 2016 09:50
-
-
Save pmcalabrese/d2d44d5f2c983c9b8ca326b8c0830fb7 to your computer and use it in GitHub Desktop.
Python email validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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