<TR>[\s\S]*?href=".*?>(.*?)<恭喜你,共匹配到数据有3项编号              组名
第1个组的组名为:   0所匹配的结果如下:1、 <TR>
     <TD> <A 
      href="http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%D8%CD%BC">湖南地图 <
2、 <TR>
     <TD> <A 
      href="http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3">湖南电视 <
3、 <TR>
     <TD> <A 
      href="http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3%CC%A8">湖南电视台 <
第2个组的组名为:   1所匹配的结果如下:1、 湖南地图 
2、 湖南电视 
3、 湖南电视台 
自己写的regex测试工具..还8错吧..呵呵!

解决方案 »

  1.   


    using System;
    using System.Text.RegularExpressions;public class Test
    {
        static void Main()
        {
            string strHtml = @"<TR>
         <TD> <A 
          href=""http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%D8%CD%BC"">湖南地图 </A> </TD>
         <TD>624&nbsp; <SPAN class=up>↑&nbsp;+11% </SPAN> </TD>
         <TD>0&nbsp; <SPAN class=dn>↓&nbsp;-100% </SPAN> </TD>
         <TD> <A 
          href=""http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%D8%CD%BC"">查看 </A> </TD>
         <TD>&nbsp; </TD> </TR>
       <TR>
         <TD> <A 
          href=""http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3"">湖南电视 </A> </TD>
         <TD>181&nbsp; <SPAN class=dn>↓&nbsp;-25% </SPAN> </TD>
         <TD>6&nbsp; <SPAN class=dn>↓&nbsp;-54% </SPAN> </TD>
         <TD> <A 
          href=""http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3"">查看 </A> </TD>
         <TD>&nbsp; </TD> </TR>
       <TR>
         <TD> <A 
          href=""http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3%CC%A8"">湖南电视台 </A> </TD>
         <TD>896&nbsp; <SPAN class=dn>↓&nbsp;-8% </SPAN> </TD>
         <TD>6&nbsp; <SPAN class=dn>↓&nbsp;-54% </SPAN> </TD>
         <TD> <A 
          href=""http://index.baidu.com/main/word.php?word=%BA%FE%C4%CF%B5%E7%CA%D3%CC%A8"">查看 </A> </TD>
         <TD>&nbsp; </TD> </TR> ";        MatchCollection mc = Regex.Matches(strHtml, @"<TR>[\s\S]*?href="".*?>(.*?)</", RegexOptions.IgnoreCase);
            for (int i = 0; i < mc.Count; i++)
            {
                Console.WriteLine(mc[i].Groups[1].Value);
            }
            //湖南地图
            //湖南电视
            //湖南电视台        Console.ReadKey();
        }
    }
      

  2.   

    try this
    (?<=<[Aa][^>]*>)[^<>]*(?=</[Aa]>)
      

  3.   


    YourStr = 你帖子里说的那个测试字符串;
    MatchCollection mc = Regex.Matches(YourStr,@"(?<=<TR>\s*<TD>\s*<[Aa][^>]*>)[^<>]*(?=</[Aa]>)");
    foreach(Match m in mc)
    {
        MessageBox.Show(m.Value);
    }