Validating and Parsing Email Addresses

  • + 0 comments

    import re, email.utils

    for _ in range(int(input())): name, address = input().split() if re.match('[a-z][\w\-\.]+@[a-z]+.[a-z]{1,3}$', address): print(email.utils.formataddr(email.utils.parseaddr((name, address.strip('<>'))))) else: pass