发布网友 发布时间:2022-05-06 19:58
共1个回答
热心网友 时间:2022-04-18 07:24
flags=0表示不进行特殊指定,比如忽略大小写,指定语言等
re.search(pattern, string, flags=0)
import re
line = "Cats are smarter than dogs";searchObj = re.search( r'(.*) are (.*?) .*', line, re.M|re.I)if searchObj:
print "searchObj.group() : ", searchObj.group()
print "searchObj.group(1) : ", searchObj.group(1)
print "searchObj.group(2) : ", searchObj.group(2)else:
print "Nothing found!!"