Python3 正则表达式match vs search Python3 正则表达式search方法 Python3 正则表达式 查找和替换 Python3 正则表达式match vs search #!/usr/bin/python3 import re line = "Cats are smarter than dogs"; matchObj = re.match( r'dogs', line, re.M|re.I) if matchObj: print ("match --> matchObj.group() : ", matchObj.group()) else: print ("No match!!") searchObj = re.search( r'dogs', line, re.M|re.I) if searchObj: print ("search --> searchObj.group() : ", searchObj.group()) else: print ("Nothing found!!") Python3 正则表达式search方法 Python3 正则表达式 查找和替换