利用正則表達(dá)式去掉字符串中所有html內(nèi)容,得到所有文本內(nèi)容,去掉的內(nèi)容有:div,img,超連接,script腳本等html內(nèi)容。將以下例子保存為asp文件,運(yùn)行一下就知道效果了。
<%
Function RemoveHTML( strText )
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = "<[^>]*>"
RegEx.Global = True
RemoveHTML = RegEx.Replace(strText, "")
End Function
str="<html><body><a href=""a.asp"">打開</a><img src=""1.jpg""><div class=""a3"">aaa</div></body></html>"
response.wr
未經(jīng)允許不得轉(zhuǎn)載:445IT之家 » asp利用正則去掉字符串中所有html內(nèi)容