using System.Text.RegularExpressions;string s = "................";Regex re = new Regex(@"<td[^>]*>(?<data>.*?)</td>", RegexOptions.IgnoreCase|RegexOptions.Singleline);foreach (Match m in re.Matches(s))
  Console.WriteLine(m.Groups["data"].Value);

解决方案 »

  1.   

    但是,这个html文件中还有其它的代码<TD>[数据]</TD>这样的还有很多,我只想要能匹配
    <TR class=dbt4 align=middle>
      ......    
        </TR>
    之间的数据,舍弃不在这个代码块中的数据
      

  2.   

    using System.Text.RegularExpressions;string s = "................";Regex re = new Regex(@"<TR class=dbt4 align=middle>(?<value>.*?)</TR>", RegexOptions.IgnoreCase|RegexOptions.Singleline);Match m2 = re.Match(s);
    if (m2.Success)
    {
     s = m2.Groups["value"].Value;
     re = new Regex(@"<td[^>]*>(?<data>.*?)</td>",  RegexOptions.IgnoreCase|RegexOptions.Singleline); foreach (Match m in re.Matches(s))
       Console.WriteLine(m.Groups["data"].Value);
    }
      

  3.   

    or
    Regex re = new Regex(@"<TR class=dbt4 align=middle>\s*(<td[^>]*>(?<data>.*?)</td>\s*)+\s*</TR>", RegexOptions.IgnoreCase|RegexOptions.Singleline);Match m = re.Match(s);
    if (m.Success)
    {
     foreach (Capture c in m.Groups["data"].Captures)
          Console.WriteLine(c.Value);
    }