2

I want to find all br tags inside of table tag using regular expressions. This is what I have so far:

<table[^>]*>(((<br/>)(?!</table>)).)*</table>

But this code doesn't work in notepad++.

This is what am testing the regular expression with:

<table>
</table>
<table>
<br/>
</table>

Basically the last 3 lines should be found with the regular expressions but the one regular expression I listed above doesn't find anything.

developer234
  • 79
  • 3
  • 14
  • 3
    In case anyone doesn't understand j08691's reference: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – p.s.w.g Oct 15 '14 at 18:27
  • Does anyone have an answer to this question other than p.s.w.g's reference – developer234 Oct 15 '14 at 20:34

1 Answers1

5

Try

<table(?: [^<>]+)?>(?:(?!</table>).)*<br/>.*?</table>

with dot-matches-all modifier s.

Demo.

Explanation:

<table # start with an opening <table> tag
(?: [^<>]+)?
>
(?: # then, while...
    (?! #...there's no </table> closing tag here...
        </table>
    )
    . #...consume the next character
)*
<br/> # up to the first <br/>
.*? # once we've found a <br/> tag, simply match anything...
</table> #...up to the next closing </table> tag.
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149