日期:2014-05-20  浏览次数:20744 次

正则表达式提取内容
<table   border=0   cellPadding=0   cellSpacing=0   width=98%   valign=top   align=center>
<tr>
<td   width=4%> </td>
<td   colspan=2   width=92%   >
<table   border=1   cellPadding=0   cellSpacing=0   width=100%   valign=top   align=center   bordercolorlight= "#CCCCCC "   bordercolordark= "#ccffcc ">
<tr   height=26   bgcolor=#E3E3E3> <td   colspan=4   align=center   class=xt> <font   color=black> 第一卷     莫名其妙&nbsp;&nbsp;&nbsp;[   <a   href= '# '   onclick=window.open( 'readchapterall.asp?bl_id=95133&bookchapterid=201 ')   > 分卷阅读 </a>   ] </td> </tr> <tr   vlign=top   class=xt   align=left   style= 'padding:4 '> <td   width= '33.3333333333333% '>
<a   href= 'javascript:gotopage(2533768) '   title= '本章字数:2835   更新日期:2007-1-22 '   target=_top> 第一章   色狼下山 </a>

</td> <td   width= '33.3333333333333% '> <a   href= 'javascript:gotopage(2533771) '
  title= '本章字数:2311

更新日期:2007-1-22 '  
target=_top> 第二章   遭遇怪兽 </a> </td> <td   width= '33.3333333333333% '> <a   href= 'javascript:gotopage(2533775) '
  title= '本章字数:2307

更新日期:2007-1-22 '  
target=_top> 第三章   人妖同流 </a> </td> </tr> <tr   vlign=top   class=xt   align=left   style= 'padding:4 '> <td   width= '33.3333333333333% '> <a   href= 'javascript:gotopage(2535077) '
  title= '本章字数:2651

更新日期:2007-1-23 '  
target=_top> 第四章   英雄落魄 </a> </td> <td   width= '33.3333333333333% '> <a   href= 'javascript:gotopage(2537127) '
  title= '本章字数:2705

更新日期:2007-1-23 '  
target=_top> 第五章   末日神功 </a> </td> <td   width= '33.3333333333333% '> <a   href= 'javascript:gotopage(2539099) '
  title= '本章字数:3270

更新日期:2007-1-24 '  
target=_top> 第六章   初入警局 </a> </td> </tr> <tr   vlign=top   class=xt   align=left   style= 'padding:4 '> <td   width= '33.3333333333333% '> <a   href= 'javascript:gotopage(2541114) '
  title= '本章字数:3206

更新日期:2007-1-24 '  
target=_top> 第七章   命相奇术 </a> </td> <td> &nbsp; </td> <td> &nbsp; </td> </tr>
</table>
</td>
<td   width=4%> </td>
</tr>
</table>

</table>
      不知怎样用正则表达式将 'javascript:gotopage(2541114)中的数字取出和将章节名称-例如:“第七章   命相奇术”取出。要取出全部章节。

------解决方案--------------------
汗哪,刚才在那个帖子里问楼主是不是这个意思,楼主那么快就结帖了,那样取出来根本就是毫无意义的,试下下面的

MatchCollection mc=Regex.Matches(yourStr,@ "gotopage\((? <number> \d+)\)[\s\S]*?> (? <title> [\s\S]*?) </a> ",RegexOptions.IgnoreCase);

foreach(Match m in mc)
{

m.Groups[ "number "].Value;   //数字串
m.Groups[ "title "].Value; //标题

}