C# 中正则表达式

其实正则表达式都差不多,这里只是简单做个记录,防止忘记

例子:

static void Main(string[] args)
        {
            string str = "j5sjf333jw";
            string reg = @"^[dA-Za-z]*$";
            Match match = Regex.Match(str,reg);
            if (match.Success)
            {
                Console.WriteLine("输入正确!");
            }
            else
            {
                Console.WriteLine("输入有误!");
            }
            //Regex reg = new Regex(@"^[0 - 9] * $");
            //string modified = reg.Replace(str, "NAME=WANG;");

            //Console.WriteLine(modified);


            //Match match = reg.Match(str);
            //string value = match.Groups[1].Value;
            //Console.WriteLine("value的值为:{0}", value);
            Console.ReadKey();
        }
原文地址:https://www.cnblogs.com/qudeqiang/p/9173671.html