Validating Email Addresses With a Filter

  • + 0 comments
    import re
    
    def fun(s):
        # return True if s is a valid email, else return False
        pattern = r"^[\w-]+@[a-zA-Z0-9]+\.[a-zA-Z]{1,3}$"
        if re.match(pattern, s) is None:
            return False
        else:
            return True