using System.Text.RegularExpressions;
private void btCheckName_Click(object sender, System.EventArgs e)
{
string UserName = this.UserName.Text.Replace("'","''").ToString();
if(UserName!="")
{
Regex regExp = new Regex("^[0-9A-Za-z]{3,16}$");
if(regExp.IsMatch(UserName))
{
.......
}
}
}
本文介绍了一个简单的用户名验证逻辑实现,使用正则表达式确保输入的用户名符合特定格式:必须为3到16个字符,且只能包含数字和字母。

1700

被折叠的 条评论
为什么被折叠?



