復(fù)制代碼 代碼如下:
Function RemoveHTML(strHTML) '過濾HTML代碼的函數(shù)包括過濾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>"
'進(jìn)行匹配
Set Matches = objRegExp.Execute(strHTML)
' 遍歷匹配集合,并替換掉匹配的項(xiàng)目
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
'取閉合的>
objRegExp.Pattern = "script(.+?)/script>"
'進(jìn)行匹配
Set Matches = objRegExp.Execute(strHTML)
' 遍歷匹配集合,并替換掉匹配的項(xiàng)目
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
'取閉合的>
objRegExp.Pattern = ".+?>"
'進(jìn)行匹配
Set Matches = objRegExp.Execute(strHTML)
' 遍歷匹配集合,并替換掉匹配的項(xiàng)目
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
End Function
您可能感興趣的文章:- js中過濾特殊字符的正則表達(dá)式
- php完全過濾HTML,JS,CSS等標(biāo)簽
- js過濾HTML標(biāo)簽以及空格的思路及代碼
- AngularJS的內(nèi)置過濾器詳解
- 防止xss和sql注入:JS特殊字符過濾正則
- 利用javascript/jquery對(duì)上傳文件格式過濾的方法
- 詳解AngularJS中的filter過濾器用法
- 用于過濾空白字符的幾種常見的js正則表達(dá)式pattern
- JS對(duì)大量數(shù)據(jù)進(jìn)行多重過濾的方法