Discuss / Python / 练习二答案

练习二答案

Topic source

zx_sunrise

#1 Created at ... [Delete] [Delete and Lock User]
def name_of_email(addr):
    g = re.match(r'(?:<([\w\s]+)> )?([\w\.]+)@\w+\.\w+', addr)
    if not g:
        return None

    if g.group(1):
        return g.group(1)

    if g.group(2):
        return g.group(2)

  • 1

Reply