重庆招考信息网 登陆:清除從word粘貼過來多餘html代碼的ClearWord函數
来源:百度文库 编辑:九乡新闻网 时间:2024/10/06 00:09:34
我們在利用FckEditor編輯器的時候會有一個清除從Word粘貼過來的多餘html代碼的功能,它是利用javascript編寫的。有了這項功能以後,我們的網頁內容可以直接從Word拷貝粘貼而不用擔心內容裏會有一大堆多餘的東西佔據資料庫空間影響網頁執行的性能了。那麼,我們參照了Fckeditor的javascript功能編寫了CFScript功能版本的ClearWord函數,利用該函數在頁面內容添加入庫時可以直接進行清除冗餘操作了。
function CleanWord(html)
{
html = REReplaceNocase(html,'s* ','','all');
html = REReplaceNocase(html,'.*? ',' ','all');
html = REReplaceNocase(html,'s*mso-[^:]+:[^;"]+;?','','all');
html = REReplaceNocase(html,'s*MARGIN: 0cm 0cm 0pts*;','','all');
html = REReplaceNocase(html,'s*MARGIN: 0cm 0cm 0pts*"','""','all');
html = REReplaceNocase(html,'s*TEXT-INDENT: 0cms*;','','all');
html = REReplaceNocase(html,'s*TEXT-INDENT: 0cms*"','""','all');
html = REReplaceNocase(html,'s*TEXT-ALIGN: [^s;]+;?"','""','all');
html = REReplaceNocase(html,'s*PAGE-BREAK-BEFORE: [^s;]+;?"','""','all');
html = REReplaceNocase(html,'s*FONT-VARIANT: [^s;]+;?"','""','all');
html = REReplaceNocase(html,'s*tab-stops:[^;"]*;?','','all');
html = REReplaceNocase(html,'s*tab-stops:[^"]*','','all');
html = REReplaceNocase(html,'s*face="[^"]*"','','all');
html = REReplaceNocase(html,'s*face=[^ >]*','','all');
html = REReplaceNocase(html,'s*FONT-FAMILY:[^;"]*;?','','all');
html = REReplaceNocase(html,'<(w[^>]*) class=([^ |>]*)([^>]*)','<1','all');
html = REReplaceNocase(html,'<(w[^>]*) s="([^""]*)"([^>]*)','<1','all');
html = REReplaceNocase(html,'s*s="s*"','','all');
html = REReplaceNocase(html,']*>s* s*',' ','all');
html = REReplaceNocase(html,']*>','','all');
html = REReplaceNocase(html,'<(w[^>]*) lang=([^ |>]*)([^>]*)','<1','all');
html = REReplaceNocase(html,'(.*?)','1','all');
html = REReplaceNocase(html,'(.*?)','1','all');
html = REReplaceNocase(html,'<\??xml[^>]*>','','all');
html = REReplaceNocase(html,'?w+:[^>]*>','','all');
html = REReplaceNocase(html,'s* ','','all');
html = REReplaceNocase(html,']*)>','
','all'); function CleanWord(html)
{
html = REReplaceNocase(html,'
html = REReplaceNocase(html,'
html = REReplaceNocase(html,'s*mso-[^:]+:[^;"]+;?','','all');
html = REReplaceNocase(html,'s*MARGIN: 0cm 0cm 0pts*;','','all');
html = REReplaceNocase(html,'s*MARGIN: 0cm 0cm 0pts*"','""','all');
html = REReplaceNocase(html,'s*TEXT-INDENT: 0cms*;','','all');
html = REReplaceNocase(html,'s*TEXT-INDENT: 0cms*"','""','all');
html = REReplaceNocase(html,'s*TEXT-ALIGN: [^s;]+;?"','""','all');
html = REReplaceNocase(html,'s*PAGE-BREAK-BEFORE: [^s;]+;?"','""','all');
html = REReplaceNocase(html,'s*FONT-VARIANT: [^s;]+;?"','""','all');
html = REReplaceNocase(html,'s*tab-stops:[^;"]*;?','','all');
html = REReplaceNocase(html,'s*tab-stops:[^"]*','','all');
html = REReplaceNocase(html,'s*face="[^"]*"','','all');
html = REReplaceNocase(html,'s*face=[^ >]*','','all');
html = REReplaceNocase(html,'s*FONT-FAMILY:[^;"]*;?','','all');
html = REReplaceNocase(html,'<(w[^>]*) class=([^ |>]*)([^>]*)','<1','all');
html = REReplaceNocase(html,'<(w[^>]*) s="([^""]*)"([^>]*)','<1','all');
html = REReplaceNocase(html,'s*s="s*"','','all');
html = REReplaceNocase(html,'
html = REReplaceNocase(html,'
html = REReplaceNocase(html,'<(w[^>]*) lang=([^ |>]*)([^>]*)','<1','all');
html = REReplaceNocase(html,'
html = REReplaceNocase(html,'
html = REReplaceNocase(html,'<\??xml[^>]*>','','all');
html = REReplaceNocase(html,'?w+:[^>]*>','','all');
html = REReplaceNocase(html,'
html = REReplaceNocase(html,'
]*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,'','
html = REReplaceNocase(html,'
]*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,'','
html = REReplaceNocase(html,'
]*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,'','
html = REReplaceNocase(html,'
]*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,'','
html = REReplaceNocase(html,'
]*)>','','all');
html = REReplaceNocase(html,']*)>','','all');
html = REReplaceNocase(html,'','
html = REReplaceNocase(html,'
]*)>','','all');
html = REReplaceNocase(html,'','
html = REReplaceNocase(html,'','
html = REReplaceNocase(html,'<(U|I|STRIKE)> 1>',' ','all');
html = REReplaceNocase(html,'<([^s>]+)[^>]*>s*1>','','all');
html = REReplaceNocase(html,'<([^s>]+)[^>]*>s*1>','','all');
html = REReplaceNocase(html,'<([^s>]+)[^>]*>s*1>','','all');
html = REReplaceNocase(html,'(
]*>.*?)(
)','return html;
}
---★ 本文转摘自『IT学习者』→ http://www.itlearner.com/article/2718
清除從word粘貼過來多餘html代碼的ClearWord函數
HTML颜色代码表
HTML颜色代码表
【清除Word文档的隐私信息】
jsp,html清除页面缓存
把Word转换成为html,TXT的若干办法
Word中回车符与换行符的清除方法
快速清除Word页眉横线的两则方法
Word操作技巧系列专题 - 快速清除Word页眉横线的两则方法
批量清除WPS/Word回车符
HTML 的所有语法
网页的html
常用的HTML代码
巧用粘贴在Word中滤除HTML格式
或的意思
清除/更换word文档里段落最后的向下的小箭头(软回车符号/键)
HTML
html
HTML
html
代碼的粘貼的方法
一段神奇的代碼1
【带文本框的文字代碼】
用查找与替换批量清除WPS/Word回车符