python 正则匹配 re.match() 和 re.search() 的区别

即使是在添加了多行匹配参数 re.M 的模式下, match仍然只匹配第一行的开头。seach()  加上 re.M 参数后,会对每一行都进行搜索。

所以match存在的意义是什么···以后只需要记住search就好了,正则用^ 也能对开头进行匹配。

 

 

参考:https://docs.python.org/3/library/re.html#search-vs-match

https://stackoverflow.com/questions/27198606/python-regex-findall-works-but-match-does-not

 

posted @ 2021-08-26 10:43  略略略——  阅读(246)  评论(0编辑  收藏  举报