https://docs.python.org/zh-cn/3/library/re.html
https://zhuanlan.zhihu.com/p/68014839
findall,search,sub,S
python findall
import re str = 'aabbabaabbaa' print(re.findall('a.b',str)) #['aab', 'aab'] print(re.findall('a*b',str)) #['aab', 'b', 'ab', 'aab', 'b'] *匹配前面的字符0次或者多次 print(re.findall('a.*b',str)) #['aabbabaabb'] .* 贪心算法 print(re.findall('a.*?b',str)) #['aab', 'ab', 'aab'] .*?非贪心算法,遇到开始和结束就截取 print(re.findall('a(.*?)b',str)) #['a', '', 'a'] .*?非贪心算法,只保留括号内的内容 str = '''aabbab aabbaa bb''' print(re.findall('a.*?b',str)) #['aab', 'ab', 'aab'] print(re.findall('a.*?b',str,re.S)) #['aab', 'ab', 'aab', 'aa b'] re.S不会对 进行中断