JavaScript 破除html文本名目标函数代码
<% '/* 函数名称:Zxj_ReplaceHtml ClearHtml '/* 函数说话:VBScript Language '/* 作 用:破除文件HTML名目函数 '/* 转达参数:Content (注:必要举办破除的内容) '/* 函数作者:张晓军(古城童话) QQ:382511147 '/* 函数声名:正则匹配(正则表达式)模式举办数据匹配替代
Function ClearHtml(Content) Content=Zxj_ReplaceHtml("&#[^>]*;", "", Content) Content=Zxj_ReplaceHtml("</?marquee[^>]*>", "", Content) Content=Zxj_ReplaceHtml("</?object[^>]*>", "", Content) Content=Zxj_ReplaceHtml("</?param[^>]*>", "", Content) Content=Zxj_ReplaceHtml("</?embed[^>]*>", "", Content) Content=Zxj_ReplaceHtml("</?table[^>]*>", "", Content) Content=Zxj_ReplaceHtml(" ","",Content) Content=Zxj_ReplaceHtml("</?tr[^>]*>", "", Content) Content=Zxj_ReplaceHtml("</?th[^>]*>","",Content) Content=Zxj_ReplaceHtml("</?p[^>]*>","",Content) Content=Zxj_ReplaceHtml("</?a[^>]*>","",Content) Content=Zxj_ReplaceHtml("</?img[^>]*>","",Content) Content=Zxj_ReplaceHtml("</?tbody[^>]*>","",Content) Content=Zxj_ReplaceHtml("</?li[^>]*>","",Content) Content=Zxj_ReplaceHtml("</?span[^>]*>","",Content) Content=Zxj_ReplaceHtml("</?div[^>]*>","",Content) Content=Zxj_ReplaceHtml("</?th[^>]*>", "", Content) Content=Zxj_ReplaceHtml("</?td[^>]*>", "", Content) Content=Zxj_ReplaceHtml("</?script[^>]*>", "", Content) Content=Zxj_ReplaceHtml("(javascript|jscript|vbscript|vbs):", "", Content) Content=Zxj_ReplaceHtml("on(mouse|exit|error|click|key)", "", Content) Content=Zxj_ReplaceHtml("<?xml[^>]*>", "", Content) Content=Zxj_ReplaceHtml("</?[a-z]+:[^>]*>", "", Content) Content=Zxj_ReplaceHtml("</?font[^>]*>", "", Content) Content=Zxj_ReplaceHtml("</?b[^>]*>","",Content) Content=Zxj_ReplaceHtml("</?u[^>]*>","",Content) Content=Zxj_ReplaceHtml("</?i[^>]*>","",Content) Content=Zxj_ReplaceHtml("</?strong[^>]*>","",Content) ClearHtml=Content End Function
Function Zxj_ReplaceHtml(patrn, strng,content) IF IsNull(content) Then content="" End IF Set regEx = New RegExp ' 成立正则表达式。 regEx.Pattern = patrn ' 配置模式。 regEx.IgnoreCase = true ' 配置忽略字符巨细写。 regEx.Global = True ' 配置全局可用性。 Zxj_ReplaceHtml=regEx.Replace(content,strng) ' 执行正则匹配 End Function %>
行使要领:
直接挪用 ClearHtml() (编辑:湖南网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|