def name_of_email(addr): reg = r'(^<[\w ]+>)|(^[\w]+@)' res = re.match(reg, addr).group() if res: if res.find('<') == 0 and res.find('>') == (len(res) - 1): return res[1:-1] else: return res[:-1] else: return None
Sign in to make a reply
UTOO_NAIVE
def name_of_email(addr): reg = r'(^<[\w ]+>)|(^[\w]+@)' res = re.match(reg, addr).group() if res: if res.find('<') == 0 and res.find('>') == (len(res) - 1): return res[1:-1] else: return res[:-1] else: return None