Before you say "oh no, not again" here I'm stating my case. I'm parsing part of HTML output and the only thing I'm interested in is name
and value
attributes of each <input/
> tag. HTML is actually HTML fragment, may not be well-formed. I don't have DOM or HTML parser and I don't try to parse nested elements anyway. The problem is that I don't know the order or number of attributes so it could be <input name="foo" value="boo"/>
or <input type="hidden" name=foo>
or <input id=blah value='boo' src="image.png" name="foo" type="img"/>
.
Is there a single regular expression that would get me values of name
and value
attribute in predictable order? I wouldn't have asked the question if I could assume that name
attribute always precedes value
but unfortunately this is not the case