Get name and value from the input tag
Posted
by DroidIn.net
on Stack Overflow
See other posts from Stack Overflow
or by DroidIn.net
Published on 2010-05-28T04:09:17Z
Indexed on
2010/05/28
4:11 UTC
Read the original article
Hit count: 178
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
© Stack Overflow or respective owner