############################################################### # 练习 1
############################################################### # -- coding: utf-8 -- import re
def is_valid_email(addr): return re.match(r'^([a-zA-Z0-9.]+)@(\w+.com)$', addr)
############################################################### # 练习 2
############################################################### # -*- coding: utf-8 -*- import re
def name_of_email(addr): m=re.match(r'^\<(\w{3})\s(\w{5})>\s+(\w+)\@(\w+).(\w+)$',addr) if m: return m.group(1)+' '+m.group(2) else: m=re.match(r'^(\w{3,8})\@(\w+).(\w+)$',addr) return m.group(1)
is_valid_email('.....@color.com')
Sign in to make a reply
Alvin天枭
############################################################### # 练习 1
############################################################### # -- coding: utf-8 -- import re
def is_valid_email(addr): return re.match(r'^([a-zA-Z0-9.]+)@(\w+.com)$', addr)
############################################################### # 练习 2
############################################################### # -*- coding: utf-8 -*- import re
def name_of_email(addr): m=re.match(r'^\<(\w{3})\s(\w{5})>\s+(\w+)\@(\w+).(\w+)$',addr) if m: return m.group(1)+' '+m.group(2) else: m=re.match(r'^(\w{3,8})\@(\w+).(\w+)$',addr) return m.group(1)