求一正则表达式,取出每行tr中的内容

workers 2013-02-17 10:51:07



<tr>
<td align="center" height="10" bgcolor="#e2e2e2">2012-12-20 </td>
<td align="center" height="10" bgcolor="#e2e2e2">19:33:36</td>
<td align="center" height="10" bgcolor="#e2e2e2">已收件</td>
<td align="center" height="10" bgcolor="#e2e2e2">常州市</td>
<td align="center" height="10" > </td>
<td align="center" height="10" > </td>
</tr>

<tr>
<td align="center" height="10" bgcolor="#e2e2e2">2012-12-20 </td>
<td align="center" height="10" bgcolor="#e2e2e2">20:21:00</td>
<td align="center" height="10" bgcolor="#e2e2e2">快件在 <font color='red'>常州</font>,准备送往下一站<font color='red'>常州集散中心 </font></td>
<td align="center" height="10" bgcolor="#e2e2e2">常州市</td>
<td align="center" height="10" > </td>
<td align="center" height="10" > </td>
</tr>

<tr>
<td align="center" height="10" bgcolor="#e2e2e2">2012-12-20 </td>
<td align="center" height="10" bgcolor="#e2e2e2">23:34:37</td>
<td align="center" height="10" bgcolor="#e2e2e2">快件在 <font color='red'>常州集散中心 </font>,准备送往下一站<font color='red'>杭州集散中心 </font></td>
<td align="center" height="10" bgcolor="#e2e2e2">常州市</td>
<td align="center" height="10" > </td>
<td align="center" height="10" > </td>
</tr>

<tr>
<td align="center" height="10" bgcolor="#e2e2e2">2012-12-21 </td>
<td align="center" height="10" bgcolor="#e2e2e2">03:16:44</td>
<td align="center" height="10" bgcolor="#e2e2e2">快件在 <font color='red'>杭州集散中心 </font>,准备送往下一站<font color='red'>杭州集散中心 </font></td>
<td align="center" height="10" bgcolor="#e2e2e2">杭州市</td>
<td align="center" height="10" > </td>
<td align="center" height="10" > </td>
</tr>


...全文
399 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
  var txts = Regex.Matches(txt, "(?is)<tr>(.+?)</tr>").OfType<Match>().Select(x => x.Groups[1].Value);
foreach (var item in txts)
{
Console.WriteLine("匹配内容如下:");
Console.WriteLine(item);
}
Console.Read();

效果如下:
workers 2013-02-17
  • 打赏
  • 举报
回复
引用 1 楼 q107770540 的回复:
(?is)(?<=<(tr)>).*?(?=</\1>)
你这个只读取了一行内容,我要读取所有的行
workers 2013-02-17
  • 打赏
  • 举报
回复
引用 2 楼 chinahuyong 的回复:
很简单的。 <tr>[\s\S]+?</tr>
你这个只读取了一行内容,我要读取所有的行
  • 打赏
  • 举报
回复
引用 2 楼 chinahuyong 的回复:
很简单的。 <tr>[\s\S]+?</tr>
======================================================= .NET快速开发整合框架(RDIFramework.NET),基于.NET的快速开发、整合框架,给用户和开发者最佳的.Net框架部署方案。 平台博客:[CNBLOGS]http://www.cnblogs.com/huyong [CSDN]http://blog.csdn.net/chinahuyong 交流QQ:406590790 (请注明:CSDN) 平台微博:http://t.qq.com/yonghu86 邮件交流:406590790@qq.com
  • 打赏
  • 举报
回复
很简单的。 <tr>[\s\S]+?</tr>
q107770540 2013-02-17
  • 打赏
  • 举报
回复
(?is)(?<=<(tr)>).*?(?=</\1>)
菜牛 2013-02-17
  • 打赏
  • 举报
回复
正则表达式是重复匹配的。
  • 打赏
  • 举报
回复
引用 5 楼 workers 的回复:
引用 1 楼 q107770540 的回复: (?is)(?<=<(tr)>).*?(?=</\1>) 你这个只读取了一行内容,我要读取所有的行
用Regex.Matches

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧