<div id="indexr1c1" style="position:absolute; left:0px; top:0px;width:12px; height:2426px;z-index:1; visibility:visible;">内容1</div>
<div id="indexr1c2" style="position:absolute; left:12px; top:0px;width:200px; height:70px;z-index:2; visibility:visible;">内容2</div>
让大家帮忙了,我想循环取出
1、          indexr1c1,  style,  内容1
2、          indexr1c2,  style,  内容2正则如何写?

解决方案 »

  1.   

    @"<div\s+id=[""']?(?<id>[^""'\s]*)[""']?\s+style=""(?<style>[^""']*)""\s+>(?<content>[^<>]*)</div>"Group["id"]
    Group["style"]
    Group["content"]
      

  2.   

    style?是指它的内容吗?试下
            string test = @"<div id=""indexr1c1"" style=""position:absolute; left:0px; top:0px;width:12px; height:2426px;z-index:1; visibility:visible;"">内容1</div>
    <div id=""indexr1c2"" style=""position:absolute; left:12px; top:0px;width:200px; height:70px;z-index:2; visibility:visible;"">内容2</div>";
            MatchCollection mc = Regex.Matches(test, @"<div\s+id=""(?<id>[^""]*)""\s+style=""(?<style>[^""]*)""[^>]*>(?<content>[\s\S]*?)</div>", RegexOptions.IgnoreCase);
            foreach (Match m in mc)
            {
                Response.Write(m.Groups["id"].Value + "<br>");
                Response.Write(m.Groups["style"].Value + "<br>");
                Response.Write(m.Groups["content"].Value + "<br>");
            }