@ 就是爱*笑
2024-05-19 12:02:07
最佳回答
第一种方法使用替换a = "<html>....</html>" 表示a代表上述htmla = replace(a,"<html>","")a = replace(a,"</html>","")...text1.text =a 把所有元素替换掉。就没有了因为你是html还可以使用正则表达式去除html标签。代码如下(需要引入正则表达式的dll): '/* 函数名称: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("(j**ascript|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 ****(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 20210311