日期:2014-05-16  浏览次数:21005 次

ASP过滤
在写入数据库的时候。我希望写入数据库的是数字和,符号 其他的一概不准写入数据库。如果做。

------解决方案--------------------
v = Request("xxx")
Set re = New RegExp
re.Pattern = "^[\d\,]+$"
If Not re.Test(v) Then
    Response.Write "应为数字和,"
    Response.End
End If
Set re = Nothing


------解决方案--------------------
ASP正则判断字符串是否包含字母数字符号
str="#@#@@a32"

if RegExpfind("[da-z]*", str) then
Response.write "有字母或数字"
else
Response.write "没有任何字母或数字"
end if


Function RegExpfind(patrn, strng) 
Dim regEx ' 建立变量。 
Set regEx = New RegExp ' 建立正则表达式。 
regEx.Pattern = patrn ' 设置模式。 
regEx.IgnoreCase = True ' 设置是否区分大小写。
regEx.Global = True ' 设置全局可用性。 
RegExpfind = regEx.Test(strng) ' 执行搜索测试。 
End Function