110,539
社区成员
发帖
与我相关
我的任务
分享
string file = File.ReadAllText(Server.MapPath("TextFile.txt"));
Regex reg = new Regex(@"(?is)<li[^>]*?>(?:(?!</?li).)*</li>");
foreach (Match m in reg.Matches(file))
Response.Write(m.Value + "<br/>");
/*
<li class="golden_bg">
<span class="ranking">
<span class="typeIcon" uId:typeIcon="56206986"></span>
</span>
<a href="http://profile.baihe.com/basicInfo.jsp?OppositeID=56206986" target="_blank"><img class="pic" src="http://photo6.baihe.com/2010/06/14/120_150/107F23A9C1171ED4CC068EB5347AECB7.jpg" alt=""/></a>
<p>
<a href="http://payment.baihe.com/product/search/index.jsp" target="_blank"><img src="http://images.baihe.com/images/baihe_new/images/icon/mybaihe_icon_024.gif" alt="排名优先"/></a>
<span class="os_icon" os:userId="56206986"></span>
<a href="http://profile.baihe.com/basicInfo.jsp?OppositeID=56206986" target="_blank">
笨笨
</a>
</p>
<p>27,北京,大学</p>
<a class="btn_greetings" href="javascript:sayHi(56206986)">打招呼</a>
</li>
<li>
<span class="ranking">
<span class="typeIcon" uId:typeIcon="56206986"></span>
</span>
<a href="http://profile.baihe.com/basicInfo.jsp?OppositeID=56206986" target="_blank"><img class="pic" src="http://photo6.baihe.com/2010/06/14/120_150/107F23A9C1171ED4CC068EB5347AECB7.jpg" alt=""/></a>
<p>
<a href="http://payment.baihe.com/product/search/index.jsp" target="_blank"><img src="http://images.baihe.com/images/baihe_new/images/icon/mybaihe_icon_024.gif" alt="排名优先"/></a>
<span class="os_icon" os:userId="56206986"></span>
<a href="http://profile.baihe.com/basicInfo.jsp?OppositeID=56206986" target="_blank">
笨笨
</a>
</p>
<p>27,北京,大学</p>
<a class="btn_greetings" href="javascript:sayHi(56206986)">打招呼</a>
</li>
*/
"(?is)<li>((?!</li>).)*</li>"