Python3 正则表达式search方法 Python3 正则表达式match方法 Python3 正则表达式match vs search Python3 正则表达式search方法 #!/usr/bin/python3 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!!") Python3 正则表达式match方法 Python3 正则表达式match vs search