过滤所有HTML代码和CSS,JS
程序员文章站
2022-07-02 19:35:33
复制代码 代码如下:function removehtml(strhtml) '过滤html代码的函数包括过滤css...
复制代码 代码如下:
function removehtml(strhtml) '过滤html代码的函数包括过滤css和js
strhtml = replace(strhtml,vbcrlf,"")
strhtml = replace(strhtml,chr(13)&chr(10),"")
strhtml = replace(strhtml,chr(13),"")
strhtml = replace(strhtml,chr(10),"")
strhtml = replace(strhtml," ","")
strhtml = replace(strhtml," ","")
dim objregexp, match, matches
set objregexp = new regexp
objregexp.ignorecase = true
objregexp.global = true
'取闭合的<>
objregexp.pattern = "<style(.+?)/style>"
'进行匹配
set matches = objregexp.execute(strhtml)
' 遍历匹配集合,并替换掉匹配的项目
for each match in matches
strhtml=replace(strhtml,match.value,"")
next
'取闭合的<>
objregexp.pattern = "<script(.+?)/script>"
'进行匹配
set matches = objregexp.execute(strhtml)
' 遍历匹配集合,并替换掉匹配的项目
for each match in matches
strhtml=replace(strhtml,match.value,"")
next
'取闭合的<>
objregexp.pattern = "<.+?>"
'进行匹配
set matches = objregexp.execute(strhtml)
' 遍历匹配集合,并替换掉匹配的项目
for each match in matches
strhtml=replace(strhtml,match.value,"")
next
removehtml=strhtml
set objregexp = nothing
end function
下一篇: 正则表达式,提取网页中的链接地址