I have and string variable with HTML similar to this:
<H3>Oahu</H3>
<TABLE width="100%">
<TBODY>
<TR>
<TD>XXXXXXXX</TD>
<TD>XXXXXXXX</TD>
</TR>
<TR>
<TD>XXXXXXXX</TD>
<TD>XXXXXXXX</TD></TR></TBODY></TABLE>
<H3>Maui</H3>
<TABLE>
<TBODY>
<TR>
<TD>XXXXXXXX</TD>
<TD>XXXXXXXX</TD>
</TR>
<TR>
<TD>XXXXXXXX</TD>
<TD>XXXXXXXX</TD></TR></TBODY></TABLE>
I actually have 12 or so tables non of which are nested. They follow one after the other with an <H3> tag or sometimes an extra <H1> tag between the tables. The trouble I'm having is my code:
Regex tableRegex = new Regex(@"(<TABLE (.*)>(.*)</TABLE>)", RegexOptions.Singleline);
locations = tableRegex.Match(divCompChart).Value;
Returns all 12 tables rather than just the first table. It seems as thought the Regex engine is not matching the </TABLE> with the very first end table tag but skips all of then until it finds the last instance of the end table tag.