Discuss / Python / 2016-7-18作业

2016-7-18作业

Topic source
import re
r1=re.compile(r'^(\w+\.)?\w+@\w+.\w{3}$')
e1=r1.match('someone@gmail.com')
e2=r1.match('bill.gates@microsoft.com')
if e1:
    print (e1.group())
if e2:
    print (e2.group())
import re
r2=re.compile(r'(\<\w+\s\w+\>)\s*((\w+\.)?\w+@\w+.\w{3})$')
e3=r2.match('<Tom Paris> tom@voyager.org')
if e3:
    print (e3.group())

  • 1

Reply