Hackerss.com

hackerss
hackerss

Posted on

Python Validate if a string with email is correct

import re

def validate_email(email):
    if re.match(r'^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,5}$', email):
        return True
    return False

print(validate_email('[email protected]'))
print(validate_email('jose@gmail'))
print(validate_email('josegmail.com'))
print(validate_email('[email protected]'))
print(validate_email('[email protected]'))
Enter fullscreen mode Exit fullscreen mode

Top comments (0)