开发者

Clean HTML table of formatting?

开发者 https://www.devze.com 2023-03-11 16:38 出处:网络
Anyone know of a way to clean a <table> of all formatting leaving just the basic tags and text?

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开发者_JAVA技巧 ideas?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消