C#正则表达式之特殊字符的匹配都有什么呢?让我们通过实例来看看具体的C#正则表达式之特殊字符的匹配是如何应用的:

下面提供一些简单的C#正则表达式之特殊字符的匹配示例:
- string x = "\\";
 - Regex r1 = new Regex("^\\\\$");
 - Console.WriteLine("r1 match count:" + r1.Matches(x).Count);//1
 - Regex r2 = new Regex(@"^\\$");
 - Console.WriteLine("r2 match count:" + r2.Matches(x).Count);//1
 - Regex r3 = new Regex("^\\$");
 - Console.WriteLine("r3 match count:" + r3.Matches(x).Count);//0
 - //匹配“\”
 - string x = "\"";
 - Regex r1 = new Regex("^\"$");
 - Console.WriteLine("r1 match count:" + r1.Matches(x).Count);//1
 - Regex r2 = new Regex(@"^""$");
 - Console.WriteLine("r2 match count:" + r2.Matches(x).Count);//1
 - //匹配双引号
 
C#正则表达式之特殊字符的匹配使用的基本内容就向你介绍到这里,希望对你了解和学习C#正则表达式有所帮助。
【编辑推荐】
Copyright © 2009-2022 www.wtcwzsj.com 青羊区广皓图文设计工作室(个体工商户) 版权所有 蜀ICP备19037934号