Regular Expression to remove HTML tables
September 12th, 2006
5 comments
Just figured out this regular expression to remove all tables from a HTML document:
</?table[^>]*>|</?tr[^>]*>|</?td[^>]*>|</?thead[^>]*>|</?tbody[^>]*>
Extremely useful for cleaning up prehistoric mark-up with a text editor that supports regular expression find-and-replace searches.
And to go all the way, this one removes font tags too:
</?table[^>]*>|</?tr[^>]*>|</?td[^>]*>|</?thead[^>]*>|</?tbody[^>]*>|</?font[^>]*>