``` 在此插入代码 import re
mail_test = re.compile(r'^((\w+)|(<\w+\s\w+>\s))' r'(\w+.?\w+@(gmail|microsoft|voyager).(com|org))$')
print(mail_test.match('someone@gmail.com')) print(mail_test.match('bill.gates@microsoft.com')) print(mail_test.search( '<Tom Paris> tom@voyager.org').group(4))
感觉写的好复杂,有更简单的方法吗
Sign in to make a reply
fridayily
``` 在此插入代码 import re
mail_test = re.compile(r'^((\w+)|(<\w+\s\w+>\s))' r'(\w+.?\w+@(gmail|microsoft|voyager).(com|org))$')
print(mail_test.match('someone@gmail.com')) print(mail_test.match('bill.gates@microsoft.com')) print(mail_test.search( '<Tom Paris> tom@voyager.org').group(4))
感觉写的好复杂,有更简单的方法吗