日期:2014-05-20 浏览次数:20454 次
<ul class="vv41Table"> <li class='vv4TableDIV1' > <span class="vv41A"><a href="../ddddd/sss" target="_blank">********</a></span></li> <li class='vv4TableDIV1' > <span class="vv41A"><a href="../ddddd/sss" target="_blank">********</a></span></li> <li class='vv4TableDIV1' > <span class="vv41A"><a href="../ddddd/sss" target="_blank">********</a></span></li> <li class='vv4TableDIV1' > <span class="vv41A"><a href="../ddddd/sss" target="_blank">********</a></span></li> </ul>
string s = File.ReadAllText(Server.MapPath("~/test.txt")); MatchCollection matches=Regex.Matches(s, @"(?is)(?<=<ul[^>]+class=""vv41Table""[^>]*>.*?)<a[^>]+>.*?</a>(?=.*?</ul>)"); foreach (Match match in matches) Response.Write(Server.HtmlEncode(match.Value) + "<br/>");
------解决方案--------------------
<ul class="vv41Table">
<li class='vv4TableDIV1' >
<span class="vv41A"><a href="../ddddd/sss" target="_blank">********</a></span></li>
<li class='vv4TableDIV1' >
<span class="vv41A"><a href="../ddddd/sss" target="_blank">********</a></span></li>
<li class='vv4TableDIV1' >
<span class="vv41A"><a href="../ddddd/sss" target="_blank">********</a></span></li>
<li class='vv4TableDIV1' >
<span class="vv41A"><a href="../ddddd/sss" target="_blank">********</a></span></li>
</ul>
<ul class="vv41Table1">
<li class='vv4TableDIV1' >
<span class="vv41A"><a href="../ddddd/sss" target="_blank">********</a></span></li>
<li class='vv4TableDIV1' >
<span class="vv41A"><a href="../ddddd/sss" target="_blank">********</a></span></li>
<li class='vv4TableDIV1' >
<span class="vv41A"><a href="../ddddd/sss" target="_blank">********</a></span></li>
<li class='vv4TableDIV1' >
<span class="vv41A"><a href="../ddddd/sss" target="_blank">********</a></span></li>
</ul>
------------------------------------
这样结果不正确
------解决方案--------------------