为什么这个re.search不起作用

时间:2012-03-06 04:23:03

标签: python regex

为什么re.search无法找到模式?

str = "<a href='http://'>\ntest\n'</a>"
re.search(r"<a[^>]+>.", str, re.MULTILINE)

1 个答案:

答案 0 :(得分:6)

除非您使用.

,否则

re.DOTALL将与换行符不匹配

mystr = "<a href='http://'>\ntest\n'</a>"
re.search(r"<a[^>]+>.", mystr, re.MULTILINE|re.DOTALL)
相关问题