日期:2014-05-17 浏览次数:20571 次
string input = @"<div style=""white-space:nowrap; padding-left:em;""><img src=""themes/77gu/images/circle.gif"" alt=""something"" /><a href=""2.html"">促销专购</a></div>"; string pattern = @"(?is)<div[^>]*?><img\b[^>]*?src=([""']?)([^""']*?)\1[^>]*?/>(?<Link><a[^>]*href=([""']?)([^""']*?)\3[^>]*?>(.*?)</a>)</div>"; foreach (Match m in Regex.Matches(input, pattern)) { Response.Write(m.Value); Response.Write(m.Groups["Link"].Value); Response.Write(m.Groups[4].Value); Response.Write(m.Groups[5].Value); }