Andrey
Andrey

Reputation: 400

Why this re.search not working

Why re.search can't find the pattern?

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

Upvotes: 2

Views: 553

Answers (1)

John La Rooy
John La Rooy

Reputation: 304137

. won't match a newline unless you use re.DOTALL

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

Upvotes: 6

Related Questions