日期:2014-05-17  浏览次数:20372 次

正则表达式,求助!! 急
现在我要用正则表达式获取 指定网页的一段新闻列表。 正则表达式不会写。 求高手帮忙!
<div class="zwdt_wz_2" style="height:147px;line-height:21px; display :inline ;">
  <div style=" float :left ; width:300px; overflow :hidden ;text-align :left ;">新闻标题</div>
</div>
 我现在 只要 需要获取新闻标题这 4个字 
  表达式该怎么写?

------解决方案--------------------
(?is)(?<=<div\b[^>]*?class="zwdt_wz_2"[^>]*?>\s*<div[^>]*?>).*?(?=</div>\s*</div>)
C# code

string html=@"你的html源码";
Regex reg = new Regex(@"(?is)(?<=<div\b[^>]*?class=""zwdt_wz_2""[^>]*?>\s*<div[^>]*?>).*?(?=</div>\s*</div>)");
string result=reg.Match(html).Value;//result就是你要的新闻标题

------解决方案--------------------
探讨
(?is)(?<=<div\b[^>]*?class="zwdt_wz_2"[^>]*?>\s*<div[^>]*?>).*?(?=</div>\s*</div>)

C# code

string html=@"你的html源码";
Regex reg = new Regex(@"(?is)(?<=<div\b[^>]*?class=""zwdt_wz_2""[^>]*?>\s*<di……

------解决方案--------------------
探讨
(?is)(?<=<div\b[^>]*?class="zwdt_wz_2"[^>]*?>\s*<div[^>]*?>).*?(?=</div>\s*</div>)

C# code


string html=@"你的html源码";
Regex reg = new Regex(@"(?is)(?<=<div\b[^>]*?class=""zwdt_wz_2""[^>]*?>\s*<……