You are viewing a single comment's thread. Return to all comments →
import email.utils import re N = int(input()) start = r'^' username = r'[A-Z][\w\.-]*' domain = r'[A-Z]+' extension = r'[A-Z]{1,3}' end = r'$' regex = re.compile(rf'{start}{username}@{domain}\.{extension}{end}', re.IGNORECASE) for _ in range(N): name, addr = email.utils.parseaddr(input()) match = re.match(regex, addr) if match: print(email.utils.formataddr((name, match.group(0))))
Seems like cookies are disabled on this browser, please enable them to open this website
Validating and Parsing Email Addresses
You are viewing a single comment's thread. Return to all comments →