I'm trying to match a regex (containing 1 variable) against a page of HTML code stored as a string.
The HTML string is an array, each element containing something as shown below. (I have split on a certain tag). Each element of the array contains some data of a House (name, amount of square meters, etc). Fictional of course. The point is that I need to match only 1 of these houses by matching the text between the first TD tags, and the part that I need is the VALUE (digits) in the last INPUT tag of the form.
<TR BGCOLOR=#D4C0A1>
<TD WIDTH=40%><NOBR>Luminous Arc 2</NOBR></TD>
<TD WIDTH=10%><NOBR>154 sqm</NOBR></TD>
<TD WIDTH=10%><NOBR>6460 gold</NOBR></TD>
<TD WIDTH=40%><NOBR>rented</NOBR></TD>
<TD><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
<FORM ACTION= METHOD=post><TR><TD>
<INPUT TYPE=hidden NAME=world VALUE=Olympa>
<INPUT TYPE=hidden NAME=town VALUE="Yalahar">
<INPUT TYPE=hidden NAME=state VALUE=>
<INPUT TYPE=hidden NAME=type VALUE=houses>
<INPUT TYPE=hidden NAME=order VALUE=>
<INPUT TYPE=hidden NAME=houseid VALUE=37010>
<INPUT TYPE=image NAME="View" ALT="View" SRC="" BORDER=0 WIDTH=120 HEIGHT=18>
</TD></TR></FORM></TABLE></TD></TR>
I constructed the following RegEx:
var regex = new RegExp(house + "[\\s\\S]+name=houseid value=([0-9]+)>", "i");
where house is the name of the house (in this example, Luminous Arc 2) and the part I need would be the houseid 37010.
I figured this Regex should work quite fine and give me the hit that I need, however houses[i].match(regex) returns null every time. I get no match in the string.
I have tried several approaches so far, including attempting to convert the string to a DOM Object to split up on TR tags (the conversion failed). I feel that I am close, but I am stuck.
Does anyone see why my regex might fail to work?
Kenneth