举报
落寞流浪者
哦,那个你得到的是一个数组来的,看matches 这个数组是如何位到里面的子数组的。 因为C#这样获取的数组我不知道怎么定位 matches foreach(Match m in matches) //先从matches 数组中取出Match 类型的数组, 因为带有()。 { foreach(string name in regex.GetGroupNames()) { Console.WriteLine(" capture group "{0}" value is:"{1}"" , name, m.Groups[name].Value); } } 从上面这个 m.Groups[name].Value 推测,可能 m.Groups[1].Value 就可以得到了 不过,这个m 是等于 matches[0] 还是 matches[1]就不知道了^^ matches[1].Groups[1].Value 应该是等价于 matches[1,1].value 吧 你这样试试看,因为正规表达式的(.*)得到的内容是在这个数组里的,没有C#,不能测试出这个值在C#的数组中是如何定位的 你可以试下 matches[1,1].value 不知道是不是这样写 从0到1 试一下看 从0,0 到 2,2 试试 ^^