<%
'------------------------------------
'检测是否含有禁止字符串,如果禁止字符串出现次数为5,测返回True
'参数说明:
'badWordList = 禁止字符列表(以,号隔开)
'str = 被检测字符串
'返回值 Boolean
'小男 2006
'更新no_mIss
'------------------------------------
'检测是否含有禁止字符串,如果禁止字符串出现次数为5,测返回True
'参数说明:
'badWordList = 禁止字符列表(以,号隔开)
'str = 被检测字符串
'返回值 Boolean
'小男 2006
'更新no_mIss
'------------------------------------
Function checkBadWord(ByVal badWordList,ByVal str)
str=""&str:CheckBadWord = False
Dim regEx,Matches
Set regEx = New RegExp
regEx.Global = True
'--------处理-----------
regEx.Pattern = "[^/u4E00-/u9FA5]" '取中文
str2 = regEx.Replace(str,"")
regEx.Pattern = "[^A-Za-z]"
str3 = regEx.Replace(str,"") '取英文
'------------------------
str = str3 & str2
regEx.IgnoreCase = True
regEx.Pattern = Replace(Replace(""&badWordList,"|","/|"),",","|")
Set Matches = regEx.Execute(str)
'CheckBadWord = regEx.Test(str) ''返回是否含有禁用字符串
If Matches.Count = 5 Then CheckBadWord = True '如果禁止字符出现5次,则返回True
Set regEx = Nothing
End Function
Dim a,b
a=Request.Form("a")
b="我日,abc,测试"
Response.Write checkBadWord(b,a)
%>
<form method="post" action="">
<input name="a" value="<%=a%>" />
<input type="submit" />
</form>
Function checkBadWord(ByVal badWordList,ByVal str)
str=""&str:CheckBadWord = False
Dim regEx,Matches
Set regEx = New RegExp
regEx.Global = True
'--------处理-----------
regEx.Pattern = "[^/u4E00-/u9FA5]" '取中文
str2 = regEx.Replace(str,"")
regEx.Pattern = "[^A-Za-z]"
str3 = regEx.Replace(str,"") '取英文
'------------------------
str = str3 & str2
regEx.IgnoreCase = True
regEx.Pattern = Replace(Replace(""&badWordList,"|","/|"),",","|")
Set Matches = regEx.Execute(str)
'CheckBadWord = regEx.Test(str) ''返回是否含有禁用字符串
If Matches.Count = 5 Then CheckBadWord = True '如果禁止字符出现5次,则返回True
Set regEx = Nothing
End Function
Dim a,b
a=Request.Form("a")
b="我日,abc,测试"
Response.Write checkBadWord(b,a)
%>
<form method="post" action="">
<input name="a" value="<%=a%>" />
<input type="submit" />
</form>