Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean HTML table of formatting?

Anyone know of a way to clean a <table> of all formatting leaving just the basic tags and text?

I have tries Komposer which was useless and even added more formatting rubbish of its own. I them tried Aptana but that only seems to be a text editor, again no use at all.

Any ideas?

like image 666
NickC Avatar asked Feb 03 '26 11:02

NickC


2 Answers

When you would like to clean HTML tables (e.g. when you copy them from Word or Excel to an HTML editor) you can use the online Table Cleaner at https://www.r2h.nl/tablecleaner

I strips all the formatiing and returns only clean HTML code so will you have a table without any styling.

like image 51
R2H Webdesign Avatar answered Feb 05 '26 03:02

R2H Webdesign


How about using a text editor that supports find and replace using regular expressions (such as Notepad++) to remove the unwanted attributes using one regex, and the font tags using another regex?

To match the attributes you need to remove the following regex should do the job:

( style| class| height| width)=("[A-Za-z0-9:;_ -]*"|'[A-Za-z0-9:;_ -]*'|[A-Za-z0-9:;_-]*)

To match font tags, try

<font.*font>

(I've tested these regular expressions with http://gskinner.com/RegExr/).

Edit

It turns out that Notepad++ does not support the logical OR operator in regular expressions. An alternative would be to use another text editor that does, or to write a small app/script to perform the replacements.

like image 38
Richard Ev Avatar answered Feb 05 '26 02:02

Richard Ev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!