梅开二度 激情超越

~~常用激扬的句子去激励自己的学生,为什么自己却莫名的沉沦了!~~

一个去除WORD文档沉余代码的函数

function cleanAndPaste( html) {
        // Remove all SPAN tags
        
        html = html.replace(/<\/?SPAN[^>]*>/gi, "" );
        // Remove Class attributes
        html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
        // Remove Style attributes
        html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
        // Remove Lang attributes
        html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
        // Remove XML elements and declarations
        html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
        // Remove Tags with XML namespace declarations: <o:p></o:p>
        html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
        // Replace the  
        html = html.replace(/ /, " " );
        // Transform <P> to <DIV>
        var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ;        // Different because of a IE 5.0 error
        html = html.replace( re, "<div$2</div>" ) ;
        html=html.replace(/ |\r\n/gi,'');

return html;
}

posted on 2006-11-19 19:37 梅开二度 激情超越 阅读(109) 评论(0)  编辑 收藏 引用 网摘 所属分类: Javascript


只有注册用户登录后才能发表评论。

My Links

Blog Stats

留言簿(3)

随笔分类(22)

随笔档案(21)

文章分类(48)

文章档案(44)

相册

收藏夹(40)

Favorite site

My Friends

搜索

最新评论