Tc711Com提示:正则表达式过滤标签收集[ASP] |
过滤 所有 html :
Function ReplaceHtml(ConStr)
Dim tmpReStr,regEx
tmpReStr = Cstr(ConStr)
Set regEx = New RegExp
regEx.Pattern = "<\/*[^<>]*>"
regEx.IgnoreCase = True
regEx.Global = True
tmpReStr = regEx.Replace(tmpReStr,"")
ReplaceHtml = tmpReStr
End Function
过滤 style :
Function ReplaceStyleTag(ConStr)
Dim tmpReStr,regEx
tmpReStr = Cstr(ConStr)
Set regEx = New RegExp
regEx.Pattern = "(<style)+[^<>]*>[^\0]*(<\/style>)+"
regEx.IgnoreCase = True
regEx.Global = True
tmpReStr = regEx.Replace(tmpReStr,"")
ReplaceStyleTag = tmpReStr
Set regEx = Nothing
End Function
过滤 层 div :
Function ReplaceDivTag(ConStr)
Dim tmpReStr,regEx
tmpReStr = Cstr(ConStr)
Set regEx = New RegExp
regEx.Pattern = "<(\/){0,1}div[^<>]*>"
regEx.IgnoreCase = True
regEx.Global = True
tmpReStr = regEx.Replace(tmpReStr,"")
ReplaceDivTag = tmpReStr
Set regEx = Nothing
End Function
过滤 链接 a :
Function ReplaceATag(ConStr)
Dim tmpReStr,regEx
tmpReStr = Cstr(ConStr)
Set regEx = New RegExp
regEx.Pattern = "<(\/){0,1}a[^<>]*>"
regEx.IgnoreCase = True
regEx.Global = True
tmpReStr = regEx.Replace(tmpReStr,"")
ReplaceATag = tmpReStr
Set regEx = Nothing
End Function
过滤 字体 font :
Function ReplaceFontTag(ConStr)
Dim tmpReStr,regEx
tmpReStr = Cstr(ConStr)
Set regEx = New RegExp
regEx.Pattern = "<(\/){0,1}font[^<>]*>"
regEx.IgnoreCase = True
regEx.Global = True
tmpReStr = regEx.Replace(tmpReStr,"")
ReplaceFontTag = tmpReStr
Set regEx = Nothing
End Function
过滤 span :
Function ReplaceSpanTag(ConStr)
Dim tmpReStr,regEx
tmpReStr = Cstr(ConStr)
Set regEx = New RegExp
regEx.Pattern = "<(\/){0,1}span[^<>]*>"
regEx.IgnoreCase = True
regEx.Global = True
tmpReStr = regEx.Replace(tmpReStr,"")
ReplaceSpanTag = tmpReStr
Set regEx = Nothing
End Function
过滤 object :
Function ReplaceObjectTag(ConStr)
Dim tmpReStr,regEx
tmpReStr = Cstr(ConStr)
Set regEx = New RegExp
regEx.Pattern = "<object.*?/object>"
regEx.IgnoreCase = True
regEx.Global = True
tmpReStr = regEx.Replace(tmpReStr,"")
ReplaceObjectTag = tmpReStr
Set regEx = Nothing
End Function
过滤 iframe:
Function ReplaceIFrameTag(ConStr)
Dim tmpReStr,regEx
tmpReStr = Cstr(ConStr)
Set regEx = New RegExp
regEx.Pattern = "(<iframe){1,}[^<>]*>[^\0]*(<\/iframe>){1,}"
regEx.IgnoreCase = True
regEx.Global = True
tmpReStr = regEx.Replace(tmpReStr,"")
ReplaceIFrameTag = tmpReStr
Set regEx = Nothing
End Function
过滤 script:
Function ReplaceScriptTag(ConStr)
Dim tmpReStr,regEx
tmpReStr = Cstr(ConStr)
Set regEx = New RegExp
regEx.Pattern = "(<script){1,}[^<>]*>[^\0]*(<\/script>){1,}"
regEx.IgnoreCase = True
regEx.Global = True
tmpReStr = regEx.Replace(tmpReStr,"")
ReplaceScriptTag = tmpReStr
Set regEx = Nothing
End Function
过滤 Class :
Function ReplaceClassTag(ConStr)
Dim tmpReStr,regEx
tmpReStr = Cstr(ConStr)
Set regEx = New RegExp
regEx.Pattern = "(class=){1,}(""|\'){0,1}\S+(""|\'|>|\s){0,1}"
regEx.IgnoreCase = True
regEx.Global = True
tmpReStr = regEx.Replace(tmpReStr,"")
ReplaceClassTag = tmpReStr
Set regEx = Nothing
End Function
更多的正则表达式过滤标签收集[ASP]请到论坛查看: http://BBS.TC711.COM
【 双击滚屏 】 【 评论 】 【 收藏 】 【 打印 】 【 关闭 】
来源:
互联网
日期:2012-5-25