使用Regex进行正则表达

public static string  Input(string standard)
        {
            Regex regex = new Regex(standard);
            string input = Console.ReadLine();
            while(regex.IsMatch(input)==false)
            {
                Console.Write("输入无效,请重新输入:");
                input = Console.ReadLine();
            }
            return input;
        }

posted @ 2017-02-07 16:36  Forekoy  阅读(157)  评论(0编辑  收藏  举报