void Main()
{
var html =File.ReadAllText("C:\\csdn.txt");
 
Regex reg=new Regex(@"(?is)<tr[^>]*?>(\s*<td[^>]*?>(.*?)</td>)+");
  foreach(Match m in reg.Matches(html))
  {
    foreach(Capture c in m.Groups[2].Captures)
{
Console.Write("{0}  ",string.IsNullOrEmpty(c.Value.Trim())?"空":Regex.Replace(c.Value.Trim(),"<[^>]*?>",""));
}
Console.WriteLine( );
  }
  Console.WriteLine();
  /*
 空  赵  111111  男  空  空  空  
空  牛  2222222  空  空  空  空  
空  飞  3333333  男  空  空  空  
奇  4444444  空  空  空  空  
张  5555555  空  空  空  空  
空  解  6666666  空  空  空  空  
  */
}

解决方案 »

  1.   


    void Main()
    {
    var html =File.ReadAllText("C:\\csdn.txt");
     
    Regex reg=new Regex(@"(?is)<tr[^>]*?>(\s*<td[^>]*?>(.*?)</td>)+");
    Regex regImag=new Regex(@"(?i)<img\b[^>]*?src=(['""\s]?)([^'""\s]+)\.(?:gif|png|jpg)\1[^>]*?>");
      foreach(Match m in reg.Matches(html))
      {
        foreach(Capture c in m.Groups[2].Captures)
    {
       string v=c.Value.Trim();
       string outV;
       if(regImag.IsMatch(v))
          outV=regImag.Match(v).Groups[2].Value;
    else outV=string.IsNullOrEmpty(c.Value.Trim())?"空":Regex.Replace(c.Value.Trim(),"<[^>]*?>","");
    Console.Write("{0}  ",outV);
    }
    Console.WriteLine( );
      }
     
      /*
    空  赵  111111  男  空  空  空  
    空  牛  2222222  空  空  空  空  
    空  飞  3333333  男  空  空  空  
    manage  奇  4444444  空  空  空  空  
    admin  张  5555555  空  空  空  空  
    空  解  6666666  空  空  空  空  
      */
    }
      

  2.   

    谢谢你的回答! 我还需要那个叫奇的 前面的manage和叫张的前面的admin应该如何解决呢