当前位置: 主页 > 编程知识 > asp编程 > ASP应用;利用正则表达式去掉字符串中的html内容

ASP应用;利用正则表达式去掉字符串中的html内容

时间:2010-5-5来源:站长资讯网 点击:

利用正则表达式去掉字符串中所有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)
%>

站长资讯网
. TAG: ASP 正则表达式 html
推荐内容最近更新人气排行
关于我们 | 友情链接 | 网址推荐 | 常用资讯 | 网站地图 | RSS | 留言