I have a html as string. I want to find every table element (open-close tags) with regex. I tried <table(.*?)>.*</table> pattern for it. But it doesn't work because, it matches something like between first table open tag and last table close tag.
Here is my code:
Pattern pattern = Pattern.compile("<table(.*?)>.*</table>");
and also I've tried:
Pattern pattern = Pattern.compile("<table(.*?)>.*</table>",Pattern.DOTALL);
Here is an instance:
    <table id="table1">
    </table>
    <table id="table2">
       <table id="table3">
       </table>
    </table>
My pattern finds all the elements between <table id="table1"> open tag and table2's close tag.
But I want it matches every table element with it's tag. For example: table1's open-close tags, table2's open-close tags..
Thanks for your answers.
 
     
     
    