s = ‘hello1world\nhello2world\nhello3world’
#re.M 多行模式
result1 = re.findall(r’\d.*d’, s, re.M)
print(result1)
#re.S 单行模式(可以看成将所有的字符串放在一行内匹配包括换行符\n)
result2 = re.findall(r’\d.*d’, s, re.S)
print(result2)
result3 = re.findall(r’\d.*?d’, s, re.S)
print(result3)
[‘1world’, ‘2world’, ‘3world’]
[‘1world\nhello2world\nhello3world’]
[‘1world’, ‘2world’, ‘3world’]