<table width="100%" cellpadding="0" cellspacing="1" class="grid">
  <tr align="center">
    <td width="20%" class="head">文章名称</td>
    <td width="40%" class="head">最新章节</td>
    <td width="15%" class="head">作者</td>
<td width="9%" class="head">字数</td>
    <td width="10%" class="head">更新</td>
    <td width="6%" class="head">状态</td>
  </tr>
    <tr>
    <td class="odd"><a href="http://www.33sy.com/shuyuan_info/30/30355.htm">网王同人之三生有幸</a></td>
    <td class="even"><a href="http://www.33sy.com/files/article/book/30/30355/index.html" target="_blank">正文 第一卷 第九章</a></td>
    <td class="odd">嘟小離</td>
<td class="even">17K</td>
    <td class="odd" align="center">09-04-10</td>
    <td class="even" align="center">连载</td>
  </tr>
    <tr>
    <td class="odd"><a href="http://www.33sy.com/shuyuan_info/29/29197.htm">红楼奇梦</a></td>
    <td class="even"><a href="http://www.33sy.com/files/article/book/29/29197/index.html" target="_blank">正文 四十七章</a></td>
    <td class="odd">江南鱼翁</td>
<td class="even">93K</td>
    <td class="odd" align="center">09-04-10</td>
    <td class="even" align="center">连载</td>
  </tr>
    <tr>
    <td class="odd"><a href="http://www.33sy.com/shuyuan_info/30/30539.htm">《狐狸,你在干嘛》</a></td>
    <td class="even"><a href="http://www.33sy.com/files/article/book/30/30539/index.html" target="_blank">正文 第九章 谁是小狗</a></td>
    <td class="odd">笨笨菩提</td>
<td class="even">22K</td>
    <td class="odd" align="center">09-04-10</td>
    <td class="even" align="center">连载</td>
  </tr>
    <tr>
    <td class="odd"><a href="http://www.33sy.com/shuyuan_info/28/28610.htm">&lt;&lt;擦肩而过&gt;&gt;</a></td>
    <td class="even"><a href="http://www.33sy.com/files/article/book/28/28610/index.html" target="_blank">正文 第四十二章 道歉</a></td>
    <td class="odd">kamzxj</td>
<td class="even">91K</td>
    <td class="odd" align="center">09-04-10</td>
    <td class="even" align="center">连载</td>
  </tr>
    <tr>
    <td class="odd"><a href="http://www.33sy.com/shuyuan_info/31/31162.htm">绫罗绸缎</a></td>
    <td class="even"><a href="http://www.33sy.com/files/article/book/31/31162/index.html" target="_blank">正文 民女陌然</a></td>
    <td class="odd">月千寒</td>
<td class="even">3K</td>
    <td class="odd" align="center">09-04-10</td>
    <td class="even" align="center">连载</td>
  </tr>
    <tr>
    <td class="odd"><a href="http://www.33sy.com/shuyuan_info/29/29745.htm">倾世红颜</a></td>
    <td class="even"><a href="http://www.33sy.com/files/article/book/29/29745/index.html" target="_blank">正文 【王显献计策】1</a></td>
    <td class="odd">玉宫</td>
<td class="even">128K</td>
    <td class="odd" align="center">09-04-10</td>
    <td class="even" align="center">连载</td>
  </tr>
    <tr>
    <td class="odd"><a href="http://www.33sy.com/shuyuan_info/29/29552.htm">凤凰错</a></td>
    <td class="even"><a href="http://www.33sy.com/files/article/book/29/29552/index.html" target="_blank">正文 0049</a></td>
    <td class="odd">雨痕愁雾</td>
<td class="even">95K</td>
    <td class="odd" align="center">09-04-10</td>
    <td class="even" align="center">连载</td>
  </tr>
    <tr>
    <td class="odd"><a href="http://www.33sy.com/shuyuan_info/29/29947.htm">绝情龙帝的小七宠妃</a></td>
    <td class="even"><a href="http://www.33sy.com/files/article/book/29/29947/index.html" target="_blank">正文 第042章</a></td>
    <td class="odd">刷新的墙壁</td>
<td class="even">73K</td>
    <td class="odd" align="center">09-04-10</td>
    <td class="even" align="center">连载</td>
  </tr>
    <tr>
    <td class="odd"><a href="http://www.33sy.com/shuyuan_info/30/30429.htm">双猫传奇</a></td>
    <td class="even"><a href="http://www.33sy.com/files/article/book/30/30429/index.html" target="_blank">正文 第十章 谁最温柔?</a></td>
    <td class="odd">猫的温柔</td>
<td class="even">40K</td>
    <td class="odd" align="center">09-04-10</td>
    <td class="even" align="center">连载</td>
  </tr>
    
</table>
我要滤出每一个表格的第一列网址以上表格中有10条附合,但不知道表达式怎么写
<td class="odd"><a href="http://www.33sy.com/shuyuan_info/30/30355.htm">网王同人之三生有幸</a></td>就是将每一行的第一列的网址滤出来如上,要的结果是http://www.33sy.com/shuyuan_info/30/30355.htm

解决方案 »

  1.   


    "(?<=<tr[^>]*>\\s*<td[^>]*>\\s*<a.*?href=\")[^\"]+(?=\">)"  // 应该有九个吧
      

  2.   


    "(?is)(?<=<tr[^>]*>\\s*<td[^>]*>\\s*<a.*?href=\")[^\"]+(?=\">)"  
    // 应该有九个吧
      

  3.   

    一定要正则吗?
    我以前一个处理HTTP代码用的.你看看string[] fileUrl = Exstring.GetInsideStr("代码文件","<td class=\"odd\"> <a href=\"","\">");
        /// <summary>
        /// 扩展字符串处理
        /// </summary>
        public class ExString
        {
            /// <summary>
            /// 获取该文字出现的次数
            /// </summary>
            /// <param name="str">需要查找的主体文档</param>
            /// <param name="pointStr">关键文字</param>
            /// <returns>次数</returns>
            public static int GetStrTime(string str,string pointStr)
            {
                int result = -1;//统计总数
                int nowpoint = 0;//计算当前位置
                while (nowpoint != -1)
                {
                    result++;
                    if (nowpoint == 0)
                        nowpoint = str.IndexOf(pointStr);
                    else
                        nowpoint = str.IndexOf(pointStr, nowpoint + 1);
                }
                return result;
            }        #region 获取某两个字符串里面的所有字符串
            /// <summary>
            /// 获取某两个字符串里面的所有字符串
            /// 前后标志字符不可一样
            /// </summary>
            /// <param name="str">主体文档</param>
            /// <param name="strA">前面的字符串</param>
            /// <param name="strB">后面的字符串</param>
            /// <returns>夹在中间的字符串集</returns>
            public static string[] GetInsideStr(string str, string strA, string strB)
            {
                int A = 0, B = 0;
                int AL = strA.Length;
                int BL = strB.Length;
                System.Collections.ArrayList forsave = new System.Collections.ArrayList();
                while (true)
                {
                    if (B == 0) 
                        A = str.IndexOf(strA);
                    else
                        A = str.IndexOf(strA, B + BL);//从上个B结尾处开始找A                
                    if (A != -1)//有可能A为-1
                    {
                        B = str.IndexOf(strB, A + AL);//从上面的A后面开始找B
                        if (B != -1)
                        {
                            A = str.LastIndexOf(strA, B);//从B往前找A 位置确定AB间
                            forsave.Add(str.Substring(A + AL, B - A - AL));
                        }
                        else
                            break;
                    }
                    else
                        break;
                }
                string[] result = (string[])forsave.ToArray(typeof(string));
                return result;
            }
            /// <summary>
            /// 获取某两个字符串里面的所有字符串
            /// 前后标志字符不可一样
            /// </summary>
            /// <param name="str">主体文档</param>
            /// <param name="strA">前面的字符串</param>
            /// <param name="offsetA">前面的偏移位置数(往右)</param>
            /// <param name="strB">后面的字符串</param>
            /// <param name="offsetB">后面的偏移位置数(往右)</param>
            /// <returns>夹在中间的字符串集</returns>
            public static string[] GetInsideStr(string str, string strA, int offsetA, string strB, int offsetB)
            {
                int A = 0, B = 0;
                int AL = strA.Length + offsetA;
                int BL = strB.Length + offsetB;
                System.Collections.ArrayList forsave = new System.Collections.ArrayList();
                while (true)
                {
                    if (B == 0)
                        A = str.IndexOf(strA);
                    else
                        A = str.IndexOf(strA, B + BL);//从上个B结尾处开始找A
                    if (A != -1)//有可能A为-1
                    {
                        B = str.IndexOf(strB, A + AL);//从上面的A后面开始找B
                        if (B != -1)
                        {
                            A = str.LastIndexOf(strA, B);//从B往前找A 位置确定AB间
                            forsave.Add(str.Substring(A + AL, B - A - AL));
                        }
                        else
                            break;
                    }
                    else
                        break;
                }
                string[] result = (string[])forsave.ToArray(typeof(string));
                return result;
            }
            /// <summary>
            /// 获取某两个字符串里面的所有字符串
            /// 前后标志字符不可一样
            /// </summary>
            /// <param name="getindex">获取第几个匹配的字符(无则返回null)</param>
            /// <param name="str">主体文档</param>
            /// <param name="strA">前面的字符串</param>
            /// <param name="strB">后面的字符串</param>
            /// <returns>夹在中间的字符串集</returns>
            public static string GetInsideStr(int getindex,string str, string strA, string strB)
            {
                int A = 0, B = 0;
                int AL = strA.Length;
                int BL = strB.Length;
                System.Collections.ArrayList forsave = new System.Collections.ArrayList();
                while (true)
                {
                    if (B == 0)
                        A = str.IndexOf(strA);
                    else
                        A = str.IndexOf(strA, B + BL);//从上个B结尾处开始找A                
                    if (A != -1)//有可能A为-1
                    {
                        B = str.IndexOf(strB, A + AL);//从上面的A后面开始找B
                        if (B != -1)
                        {
                            A = str.LastIndexOf(strA, B);//从B往前找A 位置确定AB间
                            forsave.Add(str.Substring(A + AL, B - A - AL));
                        }
                        else
                            break;
                    }
                    else
                        break;
                }
                string[] result = (string[])forsave.ToArray(typeof(string));
                try
                {
                    return result[getindex - 1];
                }
                catch
                {
                    return null;
                }
            }
            /// <summary>
            /// 获取某两个字符串里面的所有字符串
            /// 前后标志字符不可一样
            /// </summary>
            /// <param name="str">主体文档</param>
            /// <param name="getindex">获取第几个匹配的字符(无则返回null)</param>
            /// <param name="strA">前面的字符串</param>
            /// <param name="offsetA">前面的偏移位置数(往右)</param>
            /// <param name="strB">后面的字符串</param>
            /// <param name="offsetB">后面的偏移位置数(往右)</param>
            /// <returns>夹在中间的字符串集</returns>
            public static string GetInsideStr(int getindex, string str, string strA
                , int offsetA, string strB, int offsetB)
            {
                int A = 0, B = 0;
                int AL = strA.Length + offsetA;
                int BL = strB.Length + offsetB;
                System.Collections.ArrayList forsave = new System.Collections.ArrayList();
                while (true)
                {
                    if (B == 0)
                        A = str.IndexOf(strA);
                    else
                        A = str.IndexOf(strA, B + BL);//从上个B结尾处开始找A
                    if (A != -1)//有可能A为-1
                    {
                        B = str.IndexOf(strB, A + AL);//从上面的A后面开始找B
                        if (B != -1)
                        {
                            A = str.LastIndexOf(strA, B);//从B往前找A 位置确定AB间
                            forsave.Add(str.Substring(A + AL, B - A - AL));
                        }
                        else
                            break;
                    }
                    else
                        break;
                }
                string[] result = (string[])forsave.ToArray(typeof(string));
                try
                {
                    return result[getindex - 1];
                }
                catch
                {
                    return null;
                }
            }
            #endregion
        }
      

  4.   


                Regex re = new Regex("(?is)(?<=<tr[^>]*>\\s*<td[^>]*>\\s*<a.*?href=\")[^\"]+(?=\">)");
                Match m = re.Match(input);
                while (m.Success)
                {
                    Console.WriteLine(m.Value);
                    m = m.NextMatch();
                }// 我是这样用的 是可以的