I want to print out the first html tags thats has attributes
test
test2
You should use a non-greedy match for any number of characters to the left of the =
, so:
r'<.*?=.*?>'
That will match a <
, followed by a minimum number of characters, followed by a =
, followed by the minimum number of characters until the >
.
What you had:
r'=.*?>'
Means an optional <
, followed by a =
, followed by any string going up to the >
. Since the <
is optional and would only match if right before the =
, you end up with no matches for it.