网络编程
位置:首页>> 网络编程>> Asp编程>> asp 实现检测字符串是否为纯字母和数字组合的函数

asp 实现检测字符串是否为纯字母和数字组合的函数

 来源:asp之家 发布时间:2009-10-04 20:39:00 

标签:正则表达式,数字,字母

asp正则表达式检测字符串是否是数字及字母。

<% 
'函数:CheckString(strng) 
'参数:strng,待验证字符串 
'描述:检测字符串是否为纯字母和数字组合 
'示例:<%=CheckString(strng)%> 
Function CheckString(strng) 
    CheckString = true 
    Dim regEx, Match 
    Set regEx = New RegExp 
    regEx.Pattern = "^[A-Za-z0-9]+$" 
    regEx.IgnoreCase = True 
    Set Match = regEx.Execute(strng) 
    if match.count then CheckString= false 
End Function 
%>

检测是否为中文字符

<% 
'函数:CheckChinese(strng) 
'参数:strng,待验证字符 
'描述:检测是否为中文字符,返回值:中文为true,否则false 
'示例:<%=CheckChinese(strng)%> 
Function CheckChinese(strng) 
    CheckChinese = true 
    Dim regEx, Match 
    Set regEx = New RegExp 
    regEx.Pattern = "\wsws\#ws\&ws\?ws\@ws\%ws\*ws\/ws\.ws\,ws\;ws\'ws\:ws\-ws\_ws\+ws\^ws\""ws\=ws\<ws\>ws\ " 
    regEx.IgnoreCase = True 
    Set Match = regEx.Execute(strng) 
    if match.count then CheckChinese= false 
End Function 
%>


 

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com