110,571
社区成员
发帖
与我相关
我的任务
分享
string pattern=@"^\w{4,8}$";
string pattern=@"^[0-9a-zA-Z-]{4,8}$";
^(?i)[a-z0-9\-]{4,8}$
class Program {
static void Main(string[] args) {
Regex regex = new Regex(@"^[\w\-]{4,8}$");
Console.WriteLine(regex.IsMatch("a0-sde"));
Console.WriteLine(regex.IsMatch("--"));
Console.WriteLine(regex.IsMatch("a0-sde$"));
Console.WriteLine(regex.IsMatch("a0-ss22---Ade"));
Console.Read();
}
}