I have a html input element from which I need to extract the name and value using two separate regex (Java).
<INPUT type="hidden" id="Region" value="Circuits Japan" checked="false">
I need to extract Region and Circuits Japan from above using 2 different regex.
For id extraction, I used something like this .*id=(.[^"]+) and it gives me
Region value=Circuits Japan checked=false>
whereas I’m trying to extract only “Region”.
Any inputs will be much appreciated.
Cheers:-)
First of all: parsing attributes of html using a single regex is hard to do, because order of attributes can vary.
If you want to do multiple passes it’s not that hard.
Given that you don’t have
"then the regex for id would be:id=(\\S+)Of course you can’t parse multiple word attributes like that. You will need
"just to properly represent such attributes. Assuming you have multiword attribute with"around then you should use:someAttribute=\\"([^"]+)