本帖最后由 zhenghaihaihai 于 2012-07-02 22:11:09 编辑

解决方案 »

  1.   

    string s = @"你的...";
    Match match = Regex.Match(s, @"(?is)文件名称:.*?<td class=""row2"" width=""85%"">(?<文件名>.+?)</td>");
    Console.WriteLine(match.Groups["文件名"].Value);
    match = Regex.Match(s, @"(?is)下载地址:.*?<a href=""(?<下载地址>.+?)"">下载</a>");
    Console.WriteLine(match.Groups["下载地址"].Value);
    输出:
    非笔试类课程期末考核要求说明及评(软件工程).doc
    file_do.php?file_id=155909 
      

  2.   

    string tempStr = File.ReadAllText(@"C:\Users\M\Desktop\Test.txt", Encoding.GetEncoding("GB2312"));
                string pattern = @"<td[^>]*?class=(['""])row2\1[^>]*?>([^<]*?\.[^<]*)[\s\S]*?<td[^>]*?class=(['""])row2\3[^>]*?><a[^>]*?href=(['""])([^'""]*?)\4[^>]*?>";
                Match m = Regex.Match(tempStr,pattern);
                string fileName = m.Groups[2].Value;//非笔试类课程期末考核要求说明及评(软件工程).doc
                string downloadLink = m.Groups[5].Value;//file_do.php?file_id=155909
      

  3.   

    1、(?is)<tr>\s*<td\b[^>]*?><b\b[^>]*?>文件名称:</b></td>\s*<td\b[^>]*?>(?<文件名称>.*?)</td>\s*</tr>
    取Groups["文件名称"].Value或者Groups[1].Value
    2、(?is)<tr>\s*<td\b[^>]*?><b\b[^>]*?>下载地址:</b></td>\s*<td\b[^>]*?><a\s*href=(["'\s]?)([^"']*?)\1[^>]*?>.*?</a></td>\s*</tr>
    Groups[2].Value,注意双引号转义
    Regex reg=new Regex(@"(?is)<tr>\s*<td\b[^>]*?><b\b[^>]*?>下载地址:</b></td>\s*<td\b[^>]*?><a\s*href=([""'\s]?)([^""']*?)\1[^>]*?>.*?</a></td>\s*</tr>");
      

  4.   

    1. (?is)<td.*?文件名称:.*?<td[^>]*?>(?<file>.*?)</td>
     取Groups["file"].Value2.(?is)<td.*?下载地址:.*?<td[^>]*?><a[^>]*?href=(['"]?)(?<href>.*?)\1>下载</a></td>
    取Groups["href"].Value
      

  5.   

    (?is)文件名称:.*?(?=\<td)<td[^>]+>(?<file>.*?)(?=</td>).*?下载地址:.*?<a\s+href=['"](?<url>[^'"]+)['"]Groups["file"].Value="非笔试类课程期末考核要求说明及评(软件工程).doc"
    Groups["url"].Value="file_do.php?file_id=155909"