C#正则表达式判断字符串为字母或数字函数

1.判断为字母或数字

private void bool isNumOrAlp(string str)

{

    string pattern= @"^[A-Za-z0-9]+$";  //@意思忽略转义,+匹配前面一次或多次,$匹配结尾

    Match match = Regex.Match(str,pattern);

    return match.Success;

}

猜你喜欢

转载自blog.csdn.net/feiyang5260/article/details/79451034