剔除html中style,javascript,css代码

剔除页面中html中除文字以外的任何代码

<%Function RemoveHTML(str)
 Dim objRegExp, Match,strHTML
 if isnull(str) then
  str=""
 end if
 strHTML=str
 strHTML=replace(replace(replace(strHTML,vblf,""),vbcr,""),vbcrlf,"")
 

 Set objRegExp = New Regexp
 objRegExp.IgnoreCase = True
 objRegExp.Global = True

 objRegExp.Pattern = "<script[^>]*?>.*?</script>"
 strHTML  = objRegExp.Replace(strHTML,"")

 objRegExp.Pattern = "<style[^>]*?>.*?</style>"
 strHTML  = objRegExp.Replace(strHTML,"")

 objRegExp.Pattern = "<.+?>"
 strHTML  = objRegExp.Replace(strHTML,"")

 Set objRegExp = Nothing

 RemoveHTML=strHTML
End Function%>

posted @ 2010-09-29 17:54  龙圆  阅读(454)  评论(0编辑  收藏  举报