<a href="/Portals/0/201111510304674.jpg"><img alt="" style="width: 167px; height: 242px" src="http://127.0.0.1/Portals/0/BatchImages/2013/0514/635041461750963374.jpg" /></a>如上html
分别截取出href的值
/Portals/0/201111510304674.jpg和 src的值
http://127.0.0.1/Portals/0/BatchImages/2013/0514/635041461750963374.jpg谢谢啦
string html = @"<a href=""/Portals/0/201111510304674.jpg""><img alt="""" style=""width: 167px; height: 242px"" src=""http://127.0.0.1/Portals/0/BatchImages/2013/0514/635041461750963374.jpg"" /></a>";
string htmlpattern = @"(?is)<a[^>]*?href=""(?<href>[^""]*?)""[^>]*?>\s*<img[^>]*?src=""(?<src>[^""]*?)""[^>]*?/>\s*</a>";
Console.WriteLine(Regex.Match(html, htmlpattern).Groups["href"].Value);
Console.WriteLine(Regex.Match(html, htmlpattern).Groups["src"].Value);