'Asp 正则表达式 过滤 所有 html 标记 :
Function LoseHtml(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern =
"]*>"
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseHtml = ClsTempLoseStr
End function
'Asp 正则表达式 过滤 style 标记 :
Function LoseStyleTag(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern = "()+"
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseStyleTag = ClsTempLoseStr
Set regEx = Nothing
End Function
'Asp 正则表达式 过滤 层 div 标记 :
Function LoseDivTag(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern =
"]*>"
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseDivTag = ClsTempLoseStr
Set regEx = Nothing
End Function
'Asp 正则表达式 过滤 链接 a 标记 :
Function LoseATag(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern =
"]*>"
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseATag = ClsTempLoseStr
Set regEx = Nothing
End Function
'Asp 正则表达式 过滤 字体 font 标记 :
Function LoseFontTag(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern =
"]*>"
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseFontTag = ClsTempLoseStr
Set regEx = Nothing
End Function
'Asp 正则表达式 过滤 span 标记 :
Function LoseSpanTag(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern =
"]*>"
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseSpanTag = ClsTempLoseStr
Set regEx = Nothing
End Function
'Asp 正则表达式 过滤 object 标记 :
Function LoseObjectTag(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern = ""
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseObjectTag = ClsTempLoseStr
Set regEx = Nothing
End Function
'Asp 正则表达式 过滤 iframe 标记:
Function LoseIFrameTag(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern =
"(]*>[^\0]*(){1,}"
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseIFrameTag = ClsTempLoseStr
Set regEx = Nothing
End Function
'Asp 正则表达式 过滤 script :
Function LoseScriptTag(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern = "(
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseScriptTag = ClsTempLoseStr
Set regEx = Nothing
End Function
'Asp 正则表达式 过滤 Class 标记 :
Function LoseClassTag(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern =
"(class=){1,}(""|\'){0,1}\S+(""|\'|>|\s){0,1}"
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseClassTag = ClsTempLoseStr
Set regEx = Nothing
End Function
'字符串替换 Replace 的正则表达式 :
Function ReplaceReg(str,patrn,replStr,Ignor)
'=========================================
'参数解释:
'str 原来的字符串
'patrn 要替换的字符串(正则表达式)
'replStr 要替换成的字符串
'Ignor 是否区分大小写(1不区分,0区分)
'=========================================
Dim regEx ' 建立变量。
If Ingor=1 Then Ingor=true else Ingor=false
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = Ignor ' 设置是否区分大小写。
regEx.Global=True
ReplaceReg = regEx.Replace(str,replStr) ' 作替换。
End Function
'例如 将 www.xxx.com 替换成 www.xxx.comhttp://www.xxx.com">www.xxx.com>
'Response.Write(ReplaceReg("www.yyy.com","www\.xxx\.com","
href=""http://www.xxx.com"">www.xxx.com",1))