62,046
社区成员
发帖
与我相关
我的任务
分享
//^[0-9a-zA-Z]+[0-9-a-zA-Z\s]+[0-9a-zA-Z]$ 貌似这样
using System;
using System.Text.RegularExpressions;
public class Test
{
static void Main()
{
Console.WriteLine("enter username");
string str=Console.ReadLine();
bool blUser = false;
Match m = Regex.Match(str, @"^[0-9a-zA-Z]+[0-9-a-zA-Z\s]+[0-9a-zA-Z]$");
if (m.Success)
{
blUser = true;
}
Console.WriteLine(blUser);
Console.ReadLine();
}
}