标签:
string html = "<div class=‘aa‘><div class=‘left‘>324324<div>dsfsdf</div><h1>aa</h1></div></div>";
// 获取第一个 相呼应的标记
//Regex reg = new Regex(@"<div class=‘left‘>([\s\S]+?)<\/div>");
// 获取前后对应的标记
Regex reg = new Regex(@"(?is)<div class=‘left‘[^>]*>(?><div[^>]*>(?<o>)|</div>(?<-o>)|(?:(?!</?div\b).)*)*(?(o)(?!))</div>");
// 获取第一条
Match first = reg.Match(html);
// 获取匹配到的所有集合
MatchCollection list = reg.Matches(html);
foreach (Match item in list)
{
string value = item.Value;
}
标签:
原文地址:http://www.cnblogs.com/liuxiaoji/p/5969006.html