当前位置:首页 > ASP教程 > 应用技巧

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

<%
'******************************
'函数: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
%>
【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!