I'm searching through HTML documents and trying to find tables that only contain a single row. What regex can I use to do this? I've tried negative lookahead and can isolate a single row, but I don't see how to ensure that there's only a single <tr></tr>
between <table></table>
tags.
Here's the regex I'm working with now:
<table[\W].*?<tr[\W].*?<\/tr>.*(?!.*<tr[\W])<\/table>
This should NOT match the regex:
<html>
<body>
<table>
<tr>
<td>a</td>
</tr>
<tr>
<td>b</td>
</tr>
<tr>
<td>c</td>
</tr>
<tr>
<td>d</td>
</tr>
</table>
</body>
</html>
This SHOULD match the regex:
<html>
<body>
<table>
<tr>
<td>a</td>
</tr>
</table>
</body>
</html>