I have a html inside a java string. In this string I have many tables and some has div tags inside. I'm trying to get the tables with div tags using regex, but I'm having difficulty with it.
Example of string:
<table>
Normal table
</table>
<table> <--- I want to get this table
<tr>
<td>
<div>
...
</div>
</td>
</tr>
...
</table>
I tried <table.*<div.*</div>.*</table> as regex, but it gives me the whole string and not just the second table. I tried something like <table(.^(</table>))*<div.*</div>.*</table>, but it doesnt work :(
**** EDIT **** A simple code
String test = "<table>Normal table</table><table> <--- I want to get this table<tr>" +
"<td><div>...</div></td></tr>...</table>";
Pattern pattern = Pattern.compile("<table.*<div.*</div>.*</table>", Pattern.DOTALL);
Matcher matcher = pattern.matcher(test);
if( matcher.find())
System.out.println("Teste " + matcher.group());