C# String 正则表达式 Group的值疑问

为啥第二个Match的Group1,匹配到的是 "friendly."
请问大神,这个是正则表达式中哪里匹配到的?

  public class Program
    {
        static void Main(string[] args)
        {
            string input = "Yes. This dog is very friendly.";// .匹配任何字符,[.]中括号的点只配备.本身。wtf
            string pattern = @"((\w+)[\s.])+"; //默认贪婪匹配
            foreach (Match match in Regex.Matches(input, pattern))
            {
                Console.WriteLine("Match: |{0}|", match.Value);
                for (int groupCtr = 0; groupCtr < match.Groups.Count; groupCtr++)
                {
                    Group group = match.Groups[groupCtr];
                    Console.WriteLine("   Group {0}: |{1}|", groupCtr, group.Value);
                    for (int captureCtr = 0; captureCtr < group.Captures.Count; captureCtr++)
                    {
                        Console.WriteLine("      Capture {0}: |{1}|", captureCtr, group.Captures[captureCtr].Value);
                    }
                }
            }
            Console.Read();
        }
    }

图片说明

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐