當前位置:首頁 > 建站常識 > 列表

asp正則表達式過濾标簽html,style ,div,font,span,Object,iframe

點擊:時(shí)間:2017/11/24關鍵詞:上海網站設計 asp正則表達式
<%'過濾 所有 html :Function ReplaceHtml(ConStr) Dim tmpReStr, regEx tmpReStr = CStr(ConStr) Set regEx = New RegExp regEx.Pattern =
正則表達式

<%

'過濾 所有 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

%>

預約建站
免費提供網站優化(huà)
領取關鍵詞