For an example input of:
<a href="abc" something=b foo="bar" baz=cool>
I am trying to match:
something=b
baz=cool
However, everything I end up with will only match the first one (something=b), even when using preg_match_all. The regular expression I am using is:
<\w+.*?(\w+=[^"|^'|^>]).*?>
Or:
<\w+ # Word starting with <
.*? # Anything that comes in front of the matching attribute.
(
\w+ # The attribute
=
[^"|^'|^>]+? # Keep going until we find a ", ' or >
)
.*? # Anything that comes after the matching attribute.
> # Closing >
I'm probably doing something horribly wrong, pretty new to regular expressions. Please advise! :)
edit:
Revised regular expression:
<\w+.*?\w+=([^"\'\s>]+).*?>
I want it to match zzz=aaa there too ;)