當前位置:首頁 > 建站常識 > 列表

ASP過濾html函數隻保留純文字

點擊:時(shí)間:2016/12/10關鍵詞:ASP html 函數
<% Function RemoveHTML(strHTML)'過濾HTML代碼的(de)函數包括過濾CSS和(hé)JSStrHtml = Replace(StrHtml,vbCrLf,"") StrHtml = Replace(StrHtml,Chr(13)
ASP過濾html函數隻保留純文字
<%  Function RemoveHTML(strHTML)    '過濾HTML代碼的(de)函數包括過濾CSS和(hé)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  '取閉合的(de)<>   objRegExp.Pattern = "<style(.+?)/style>"   '進行匹配   Set Matches = objRegExp.Execute(strHTML)  ' 遍曆匹配集合,并替換掉匹配的(de)項目   For Each Match in Matches   strHtml=Replace(strHTML,Match.Value,"")   Next  '取閉合的(de)<>   objRegExp.Pattern = "<script(.+?)/script>"   '進行匹配   Set Matches = objRegExp.Execute(strHTML)  ' 遍曆匹配集合,并替換掉匹配的(de)項目   For Each Match in Matches   strHtml=Replace(strHTML,Match.Value,"")   Next  '取閉合的(de)<>   objRegExp.Pattern = "<.+?>"   '進行匹配   Set Matches = objRegExp.Execute(strHTML)   ' 遍曆匹配集合,并替換掉匹配的(de)項目   For Each Match in Matches   strHtml=Replace(strHTML,Match.Value,"")   Next  RemoveHTML=strHTML   Set objRegExp = Nothing   End Function  %>  
預約建站
免費提供網站優化(huà)
領取關鍵詞