当前位置:首页 > 网络编程 > WEB编程 > ASP > asp利用正则表达式去掉字符串中所有html内容

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

点击次数:192 次 发布日期:2008-09-18 15:09:00 作者:源代码网
源代码网推荐

源代码网整理以下利用正则表达式去掉字符串中所有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)
%>

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华