一聚教程网:一个值得你收藏的教程网站

热门教程

asp中正则表达式过滤html代码函数

时间:2022-06-30 10:50:41 编辑:袖梨 来源:一聚教程网

 代码如下 复制代码

<%
Option Explicit

Function stripHTML(strHTML)
'Strips the HTML tags from strHTML

Dim objRegExp, strOutput
Set objRegExp = New Regexp

objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<.+?>"

'Replace all HTML tag matches with the empty string
strOutput = objRegExp.Replace(strHTML, "")

'Replace all < and > with < and >
strOutput = Replace(strOutput, "<", "<")
strOutput = Replace(strOutput, ">", ">")

stripHTML = strOutput 'Return the value of strOutput

Set objRegExp = Nothing
End Function
%>

使用方法

 代码如下 复制代码

stripHTML(strhtml)就可以了,这样用起来就方便多了

热门栏目