regex - What regular expression can I use to find in an HTML document tables that only contain one row? -


i'm searching through html documents , trying find tables contain single row. regex can use this? i've tried negative lookahead , can isolate single row, don't see how ensure there's single <tr></tr> between <table></table> tags.

here's regex i'm working now:

<table[\w].*?<tr[\w].*?<\/tr>.*(?!.*<tr[\w])<\/table> 

this should not match 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 regex:

<html>  <body>   <table>     <tr>       <td>a</td>     </tr>   </table> </body>  </html> 

this should work: <table>(?>[^<]++|<(?!\/tr>))*<\/tr>(?>[^<]++|<(?!\/tr>))<\/table>

it looking 1 instance of </tr> between <table> , </table>.

details can found here: negative lookaround regex - 1 occurrence - java


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -