本帖最后由 u010936098 于 2013-06-28 09:31:20 编辑

解决方案 »

  1.   

    if (mc.Success)
                {
       
                        foreach (Capture cp in mc.Groups["low_bound"].Captures)
                        {
                            //do something with name and cp.value
                        }
                    
                 }
                
      

  2.   

      Regex testXpress = new Regex("(?<dd>)[\u4e00-\u9fa5]+");
    Match mc = testXpress.Match("dsafdsa真大事fdsfgdsag国防生23423");
    string xx = mc.Groups["dd"].Value;xx就是对应捕获组dd所捕获的值啊
      

  3.   

    这我知道。我不是要按名字去访问,而是要遍历所有的捕获组,然后根据名字去处理值。问题的关键在于,事先不知道有哪些命名捕获组,否则我就可以把组名写成一个数组去遍历了。it is also easy:GroupCollection groups = regex.Match(line).Groups;foreach (string groupName in regex.GetGroupNames())
    {
        Console.WriteLine(
           "Group: {0}, Value: {1}",
           groupName,
           groups[groupName].Value);
    }
      

  4.   

    这我知道。我不是要按名字去访问,而是要遍历所有的捕获组,然后根据名字去处理值。问题的关键在于,事先不知道有哪些命名捕获组,否则我就可以把组名写成一个数组去遍历了。it is also easy:GroupCollection groups = regex.Match(line).Groups;foreach (string groupName in regex.GetGroupNames())
    {
        Console.WriteLine(
           "Group: {0}, Value: {1}",
           groupName,
           groups[groupName].Value);
    }严重同意