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
过滤图片正则表达式
<img.+?>
Asp过滤Html代码方法二
Function delHtml(strHtml)
Dim objRegExp, strOutput Set objRegExp = New Regexp ' 建立正则表达式
function coder(str) dim i if isnull(str) then : coder="" : exit function : end if for i = 1 to len(str) select case mid(str,i,1) case "<" : coder = coder &"<" case ">" : coder = coder &">" case "&" : coder = coder &"&" case chr(9) : coder = coder &" " case chr(13) : coder = coder &"<br>" case chr(32) : coder = coder &" " case chr(34) : coder = coder &""" case chr(39) : coder = coder &"'" case else : coder = coder & mid(str,i,1) end select next end function
过滤javascript字符
function movejs(str) dim objregexp,str1
set objregexp=new regexp
objregexp.ignorecase =true
objregexp.global=true
objregexp.pattern="\<script.+?\<\/script\>"
a=objregexp.replace(str,"")
objregexp.pattern="\<[^\<]+>"
movejs=objregexp.replace(a,"") end function
过滤html标签只剩<br>
function filterhtml(byval fstring) if isnull(fstring) or trim(fstring)="" then filterhtml="" exit function end if