日期:2014-05-17 浏览次数:20456 次
string str = @"<div class=""info"">aaaaaa<div id=""content""> <p>ddd</p> <div id=""cc"">ddd</div> <img src=""yili120x60.gif"" /> <img src=""120x60/omj120X60.gif"" /> </div>bbbbb</div>"; Regex reg = new Regex(@"(?is)<div[^>]*?id=""content"">((?:(?<Open><div[^>]*?>)|(?<-Open></div>)|.*?)*)(?(Open)(?!))</div>"); Console.WriteLine(reg.Match(str).Groups[1].Value);