本帖最后由 lijing3333 于 2012-06-18 13:48:36 编辑

解决方案 »

  1.   

    (?is)<div\sclass=(['"]?)photo\1>.*?<a\b[^>]*?href=(['"]?)(?<url>[^'"]+)\2[^>]*?>取Group["url"].Value
      

  2.   

    楼上先进啊 
    我还想说 直接用jquery获取href的内容呢。
      

  3.   


      MatchCollection matches = Regex.Matches(htmlStr, "(?is)<div\sclass=(['"]?)photo\1>.*?<a\b[^>]*?href=(['"]?)(?<url>[^'"]+)\2[^>]*?>");
                string ahtml = "";
                foreach (Match match in matches)
                {
                    ahtml += match.Groups["url"].Value + "\r\n";
                }取不出来啊  报错了。
      

  4.   

    (?is)<div\b[^>]*?class="photo">[^>]*?<a\b[^>]*?href=(["'\s]?)([^"']*?)\1[^>]*?>
    取第二个分组,Groups[2].Value
      

  5.   


    MatchCollection matches = Regex.Matches(htmlStr, @"(?is)<div\sclass=(['""]?)photo\1>.*?<a\b[^>]*?href=(['""]?)(?<url>[^'""]+)\2[^>]*?>");
      string ahtml = "";
      foreach (Match match in matches)
      {
      ahtml += match.Groups["url"].Value + "\r\n";
      }