Email Validation

Description: Checks to see if a given email address is valid using a regular expression.
Tested Platform: Python 3.11
Language: Python
import re

def is_valid_email(email_address):
    """Validates if the email address provided is valid."""
    regex = re.fullmatch(r"([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|\"([]!#-[^-~ \t]|(\\[\t -~]))+\")@([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|\[[\t -Z^-~]*])", str(email_address))
    return regex is not None

Posted: March 21, 2023

Return to the snippets listing