We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Validating and Parsing Email Addresses
Validating and Parsing Email Addresses
Sort by
recency
|
333 Discussions
|
Please Login in order to post a comment
I managed to use both regex and email.util
import email.utils import re noOfInp = int(input()) pattern = r'^[a-zA-Z]+[\w-.]+@[a-zA-Z]+.{1}[a-zA-Z]{1,3}$'
def isValidEmail(username, mail): m = re.match(pattern, mail) if m: tupl = (username, mail) print(email.utils.formataddr(tupl))
for i in range(noOfInp): inp = input() username = email.utils.parseaddr(inp)[0] mail = email.utils.parseaddr(inp)[1] isValidEmail(username, mail)
import email.utils name="" user="" domain="" ext="" a=[] out="" new_str=""
n=int(input())
def validity(n,u,d,e):
for i in range(n): a.append(input())
for email in a: if "<" in email: name,mail=email.split("<",1) if "@" in mail: user, domain_with_ext = mail.split("@", 1)