刚刚回了一次,现在再回一次,哈哈
过滤html,但不删除任何不是html的东西,如英文字符等。
Function delHtml(strHtml)
Dim objRegExp, strOutput
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "(<[a-zA-Z].*?>)|(<[\/][a-zA-Z].*?>)"
strOutput = objRegExp.Replace(strHtml, "")
strOutput = Replace(strOutput, "<", "<")
strOutput = Replace(strOutput, ">", ">")
delHtml = strOutput
Set objRegExp = Nothing
End Function
如果你还过滤别的什么东东
直接加代码如:
把文章中的“某某某”换成“XXX”
strOutput = Replace(strOutput, "某某某", "XXX")
把文章中的“ ”删除
strOutput = Replace(strOutput, " ", "")
Function RemoveHTML(str)
Dim re
Set re=New RegExp
re.Pattern="<.*?>"
re.IgnoreCase=True
re.Global=True
str=re.Replace(str,"")
Set re=Nothing
RemoveHTML=str
End Function
过滤掉html字符 只需要输出的时候调用以下就ok
<%
Function RemoveHTML(strHTML)
ON ERROR RESUME NEXT
Dim objRegExp, strOutput
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<.+?>"
strOutput = objRegExp.Replace(strHTML, "")
strOutput = Replace(strOutput, "<", "〈")
strOutput = Replace(strOutput, ">", "〉")
strOutput = Replace(str0utput, "", "")
RemoveHTML = strOutput
Set objRegExp = Nothing
End Function
%>
然后在你想要输出的地方写入:<%=RemoveHTML(rs("字段名"))%>就搞定了!