110,537
社区成员
发帖
与我相关
我的任务
分享
Console.WriteLine(Regex.Matches("172.10.10.10", ".").Count.ToString());//12
Console.WriteLine(Regex.Matches("172.10.10.10", @".").Count.ToString());//12
Console.WriteLine(Regex.Matches("172,10,10,10", ",").Count.ToString());//3
Console.WriteLine(Regex.Matches("172.10.10.10", "0.").Count.ToString());//2
Console.WriteLine(Regex.Matches("172.10.10.10", ".1").Count.ToString());//3
前两条输入12是因为 . 是通配符 若要匹配文本句点字符(. 或 \u002E),你必须在该字符前面加上转义符 (\.)。参考文档
Console.WriteLine(Regex.Matches("172.10.10.10", "\\.").Count.ToString());//3
Console.WriteLine(Regex.Matches("172.10.10.10", @"\.").Count.ToString());//3