(?m) 和 (?s) 是正则表达式中的两个模式标志,它们具有不同的作用:
import re
pattern1 = r'^.*'
pattern2 = r'(?m)^.*'
pattern3 = r'(?s)^.*'
matches1 = re.findall(pattern1, "Hello\nWorld")
matches2 = re.findall(pattern2, "Hello\nWorld")
matches3 = re.findall(pattern3, "Hello\nWorld")
print(matches1) # 输出:['Hello']
print(matches2) # 输出:['Hello', 'World']
print(matches3) # 输出:['Hello\nWorld']