Discuss / Python / 练习

练习

Topic source
import re
s1 = 'someone@gmail.com'
s2 = 'bill.gates@microsoft.com'
reg = r'^(\w*\d*.*)@(gmail|microsoft).(com)$'
print(re.match(reg, s1).groups())
print(re.match(reg, s2).groups())

s3 = '<Tom Paris> tom@voyager.org'
print(re.match(r'^<(\W?\w* \W?\w*)> (\w+)@(\w+).(\w+)$', s3).groups())

  • 1

Reply