Asp编程

asp利用正则去掉字符串中所有html内容

日期:2015/6/28来源: IT猫扑网

利用正则表达式去掉字符串中所有html内容,得到所有文本内容,去掉的内容有:div,img,超连接,script脚本等html内容。将以下例子保存为asp文件,运行一下就知道效果了。


<%
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.write removehtml(str)
%>

相关文章

相关下载

网友评论

我要评论...
    没有更早的评论了
    取消