ASP何屏敝输入的HTML代码

四月 30, 2007 by admin  
类别:WEB技术

ASP用正则表达式删除HTML标签

Function Newstring(wstr,strng)
Newstring=Instr(lcase(wstr),lcase(strng))
if Newstring<=0 then Newstring=Len(wstr)
End Function
Function RemoveHTML(strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp

objRegExp.IgnoreCase = True
objRegExp.Global = True
‘取闭合的<>
objRegExp.Pattern = ”<.+?>”
‘进行匹配
Set Matches = objRegExp.Execute(strHTML)

‘ 遍历匹配集合,并替换掉匹配的项目
For Each Match in Matches
strHTML=Replace(strHTML,Match.Value,”")
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
End Function

评论

告诉我们你想说点啥...
想要有个性的头像, 到gravatar这里申请!