Python 正则表达式 匹配(match) vs 搜索(search) Python 正则表达式search函数 Python 正则表达式搜索和替换 Python 正则表达式 匹配(match) vs 搜索(search) #!/usr/bin/python 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!!" Python 正则表达式search函数 Python 正则表达式搜索和替换