有关函数
match函数
#encoding:utf-8
import re
pattern=re.compile(r’hello’)
match=pattern.match(‘hello word!!’)
if match:print(match.group())
split函数
import re
re.split(“\d+”,”one1two2three3four4”)finditer(迭代器)
import re
content = ‘’’email:12345678@163.com
email:2345678@163.com
email:345678@163.com
‘’’
result=re.finditer(r”\d+@\w+.com”,content)
for m in result:print(m.group())
findall
import re
re.findall(“\d+”,”one1two2three3four4”)