string card1="\\d{6,8}"; string card = null; do { Console.WriteLine("请输入数字!"); card = Console.ReadLine(); if (Regex.IsMatch(card, card1)) { break; } Console.WriteLine("请重新输数字!"); } while (true);