日期:2014-05-18  浏览次数:20455 次

利用正则表达式获取指定的值
<div>
<table cellspacing="0" rules="all" border="1" id="gvRouteFirendTime" style="width:100%;border-collapse:collapse;">
<tr class="td_gridView_header">
<th scope="col" style="white-space:nowrap;">开始日期</th><th scope="col" style="white-space:nowrap;">结束日期</th><th scope="col" style="white-space:nowrap;">周开始</th><th scope="col" style="white-space:nowrap;">周结束</th><th scope="col" style="white-space:nowrap;">首班车时间</th><th scope="col" style="white-space:nowrap;">末班车时间</th>
</tr><tr class="td_gridView_row">
<td style="white-space:nowrap;">11-01</td><td style="white-space:nowrap;">12-31</td><td style="white-space:nowrap;">星期一</td><td style="white-space:nowrap;">星期五</td><td style="white-space:nowrap;">05:30</td><td style="white-space:nowrap;">23:30</td>
</tr><tr class="td_gridView_row_alternate">
<td style="white-space:nowrap;">11-01</td><td style="white-space:nowrap;">12-31</td><td style="white-space:nowrap;">星期六</td><td style="white-space:nowrap;">星期日</td><td style="white-space:nowrap;">05:30</td><td style="white-space:nowrap;">23:30</td>
</tr>
</table>
</div>
  </td>
  </tr>
  </table>
  </fieldset>
  </td>
  </tr>
  <tr>
  <td>
  <fieldset>
  <legend>发车间隔



有上面这样一个结构的字符串现在要利用正则表达式获取首班车时间(05:30)和末班车时间(23:30) 请问正则表达式怎么写

------解决方案--------------------
"\b(?<n1>\d{1,3})\.(?<n2>\d{1,3})\.(?<n3>\d{1,3})\.(?<n4>\d{1,3}\b)"

------解决方案--------------------
C# code

string content = @"<div>
    <table cellspacing=""0"" rules=""all"" border=""1"" id=""gvRouteFirendTime"" style=""width:100%;border-collapse:collapse;"">
    <tr class=""td_gridView_header"">
    <th scope=""col"" style=""white-space:nowrap;"">开始日期</th><th scope=""col"" style=""white-space:nowrap;"">结束日期</th><th scope=""col"" style=""white-space:nowrap;"">周开始</th><th scope=""col"" style=""white-space:nowrap;"">周结束</th><th scope=""col"" style=""white-space:nowrap;"">首班车时间</th><th scope=""col"" style=""white-space:nowrap;"">末班车时间</th>
    </tr><tr class=""td_gridView_row"">
    <td style=""white