本帖最后由 xxaiwho 于 2012-09-14 10:24:44 编辑

解决方案 »

  1.   

    string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt
                    
                    string href = Regex.Match(tempStr, @"(?i)<tr[^>]*?BGCOLOR=(['""]?)eeeeee\1[^>]*?>(?:\s*?<td[^>]*?>[\s\S]*?</td>\s*?){2}\s*?<td[^>]*?>(?<href><a[^>]*?href=(['""]?)(\S+?)\2[^>]*?>[^<]+?</a>)</td>").Groups["href"].Value;
                    //<A HREF=http://www.jhsf.or.jp/cgi-bin/HSRRB/C_ViewDetail.cgi?jcrb=JCRB9036>JCRB9036</A>
                    //第二个循环取吧 根据索引得到
                    string pattern = @"(?i)<tr[^>]*?><td[^>]*?BGCOLOR=(['""]?)Gainsboro\1[^>]*?>[^<>]*?</td>\s*?<td[^>]*?>([^<>]+)";
                    
                    foreach (Match m in Regex.Matches(tempStr, pattern))
                    {
                        //循环输出
                        string value = m.Groups[2].Value;//JCRB1348
                        //                }
      

  2.   

    已经在1L回复,怎么不见了?
    string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt
                    
                    string href = Regex.Match(tempStr, @"(?i)<tr[^>]*?BGCOLOR=(['""]?)eeeeee\1[^>]*?>(?:\s*?<td[^>]*?>[\s\S]*?</td>\s*?){2}\s*?<td[^>]*?>(?<href><a[^>]*?href=(['""]?)(\S+?)\2[^>]*?>[^<]+?</a>)</td>").Groups["href"].Value;
                    //<A HREF=http://www.jhsf.or.jp/cgi-bin/HSRRB/C_ViewDetail.cgi?jcrb=JCRB9036>JCRB9036</A>
                    //第二个循环取吧 根据索引得到
                    string pattern = @"(?i)<tr[^>]*?><td[^>]*?BGCOLOR=(['""]?)Gainsboro\1[^>]*?>[^<>]*?</td>\s*?<td[^>]*?>([^<>]+)";
                    
                    foreach (Match m in Regex.Matches(tempStr, pattern))
                    {
                        //循环输出
                        string value = m.Groups[2].Value;//JCRB1348
                        //                }
      

  3.   

    第一个:
    <A HREF=(.*)>\w{8}
    第二个:
    第一个红色:<TD ALIGN="left">(\w{8})</FONT></TD>
      

  4.   

    new Regex("[\\w =:>/.?\\-_]{10,}[</A]{3}").Match(inputstr)
    匹配链接(new Regex("[>]{1}([\\w]{1,})[<]{1}").Match(inputstr)).Groups[1]
      

  5.   

    正则表达式不能从一堆"11111"中选出一个"1"来符合你的要求,除非位置已固定,若第二个红色字块一定位于那个<TD ALIGN="left">tumor</TD>的标签下,那就可以把所有的<TD.....</TD>匹配出来然后找到它是第pos个TD.
    new Regex("<TD[\\w=\\\" ]{1,}>(\\w{0,})</TD>").Matches(inputstr)[pos].Groups[1]