Closed Ekultek closed 7 years ago
The proposed regex would fail for ICANN-era TLDs
https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#ICANN-era_generic_top-level_domains
Did some testing:
>>> def validate_email_1(email):
import re
valid = re.compile(r"^[^@]+@[^@]+\.[^@]+$")
if valid.match(email):
print "Validation method 1 matched"
else:
print "Validation method 1 failed"
>>> def validate_email_2(email):
import re
valid = re.compile(r"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$")
if valid.match(email):
print "Validation method 2 matched"
else:
print "Validation method 2 failed"
>>> emails = ["almira_eckl@mail.com", "por.bop@msn.com", "trinit_eckley@myspace.com", "fifranc@freewebmail.com", "test@test.academy", "test@test.accountant", "test@test.accountants"]
>>> for item in emails:
validate_email_1(item)
validate_email_2(item)
Validation method 1 matched
Validation method 2 matched
Validation method 1 matched
Validation method 2 matched
Validation method 1 matched
Validation method 2 matched
Validation method 1 matched
Validation method 2 matched
Validation method 1 matched
Validation method 2 failed
Validation method 1 matched
Validation method 2 failed
Validation method 1 matched
Validation method 2 failed
On that note, closing the pull request down
Hi @Ekultek First of all, thanks a lot for your PR! It makes us specially happy to see people contributing! Please feel free to update this PR or open another with a regex that take into account the aforementioned TLDs.
@aesedepece Will do I'll figure one out, thanks. I'll reopen it when I get it fixed
Updated the email regex to be a little more accurate
Example: