当前位置: 移动技术网 > IT编程>开发语言>Asp > asp 实现检测字符串是否为纯字母和数字组合的函数

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

2017年12月12日  | 移动技术网IT编程  | 我要评论
<%
'******************************
'函数:checkstring(strng)
'参数:strng,待验证字符串
'作者:阿里西西
'日期:2007/7/13
'描述:检测字符串是否为纯字母和数字组合
'示例:<%=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,待验证字符
'作者:阿里西西
'日期:2007/7/13
'描述:检测是否为中文字符,返回值:中文为true,否则false
'示例:<%=checkchinese(strng)%>
'******************************
function checkchinese(strng)
    checkchinese = true
    dim regex, match
    set regex = new regexp
    regex.pattern = "\||\#|\&|\?|\@|\%|\*|\/|\.|\,|\;|\'|\:|\-|\_|\+|\^|\""|\=|\<|\>|\ "
    regex.ignorecase = true
    set match = regex.execute(strng)
    if match.count then checkchinese= false
end function
%>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网