Reputation: 11
I am by no means an expert and only got BBEdit for a one time project recently.
I am working on a HTML file that has lots of entries I would like to remove. The code I wish to remove are all the tables that have the string NOT CONVERTED inside them without removing all other tables that have pretty much the same table pattern but different text or strings inside the table.
<table border=0 width="100%">
<tr>
<td class="out" valign=top nowrap width=5%>30.12.2004
22:34:03 <font color=black><b>></b>TOM </font>
</td>
<td class="out"
align=left>{{{NOT CONVERTED}}}</td>
</tr>
</table
<table border=0 width="100%"><tr><td class="timedel" valign=top nowrap
width=5%>30.12.2004 22:36:37 <font
color=black><b><</b>Benjamin </font></td><td class="incom" align=left>random string</td></tr></table>
<table border=0 width="100%"><tr><td class="incom" valign=top nowrap width=5%>30.12.2004
22:36:47 <font color=black><b><</b>Benjamin </font></td><td
class="incom" align=left>{{{NOT CONVERTED}}}</td></tr></table>
<table border=0 width="100%"><tr><td class="timedel" valign=top nowrap
width=5%>30.12.2004 22:36:47 <font
color=black><b><</b>Benjamin </font></td><td class="incom" align=left>random chat text</td></tr></table>
<table border=0 width="100%"><tr><td class="incom" valign=top nowrap width=5%>30.12.2004
22:36:50 <font color=black><b><</b>Benjamin </font></td><td
class="incom" align=left>{{{NOT CONVERTED}}}</td></tr></table>
I have 3000 of those tables in my html file and I wish to find and remove those tables. The DATE, NAME and " >" are variables that differ in each table, the rest always has the same pattern.
How can I use the grep feature in this instance to identify this pattern and have it removed.
Upvotes: 1
Views: 307
Reputation: 11
Thanks Siegel again for your help - I played around with your code and this did the trick:
<table.+?>{{{NOT CONVERTED}}}.+?</table>
This successfully identified the tables that had the string not converted in them.
Thanks again !
Upvotes: 0
Reputation: 990
If you simply want to remove the entire table (from the opening <table>
to the ending </table>
), if the string "{{{NOT CONVERTED}}}" appears in the middle of it, then this pattern will match the entire table:
(?s)<table.+?>.+?{{{NOT CONVERTED}}}.+?</table>\n
(The (?s)
at the beginning allows .
to match across line breaks.)
Use "Replace All", replacing with nothing, to delete all of the eligible tables. Undo is your friend if it doesn't do what you need.
Upvotes: 1