'-------------------去掉html js css
Function delHtml(strHtml)
Dim objRegExp, strOutput
Set objRegExp = New Regexp '' 建立正则表达式
objRegExp.IgnoreCase = True '' 设置是否区分大小写
objRegExp.Global = True ''是匹配所有字符串还是只是第一个
objRegExp.Pattern = "(<[a-zA-Z!*].*?>)|(<[\/][a-zA-Z!*].*?>)" '' 设置模式引号中的是正则表达式,用来找出html标签
strOutput = objRegExp.Replace(strHtml, "") ''将html标签去掉
strOutput = Replace(strOutput, "<", "<") ''防止非html标签不显示
strOutput = Replace(strOutput, ">", ">")
delHtml = strOutput
Set objRegExp = Nothing
End Function
Function RemoveHTML(Textstr)
Dim sStr, regEx
sStr = Textstr
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
regEx.Multiline = True
regEx.Pattern = "<script[\s\S]*?</script>" '屏蔽 代码类的 script
sStr = regEx.Replace(sStr, "")
regEx.Pattern = "<style[\s\S]*?</style>" '屏蔽 代码类的 style
sStr = regEx.Replace(sStr, "")
' regEx.Pattern = "style=""[\s\S]*?""" '屏蔽 代码类的 style=""
' sStr = regEx.Replace(sStr, "")
' regEx.Pattern = "class=[\s\S]*? " '屏蔽 代码类的 class=
' sStr = regEx.Replace(sStr, "")
' regEx.Pattern = "\s[on].+?=([\""|\'])(.*?)\1" '屏蔽 代码类的 html
' sStr = regEx.Replace(sStr, "")
' regEx.Pattern = "<(.[^>]*)>" '屏蔽 代码类的 html
' sStr = regEx.Replace(sStr, "")
Set regEx = Nothing
RemoveHTML = sStr
End Function
调用 RemoveHTML("<a href=''>123</>")
最新评论