Regex.Matches 如何从网页中获取想要的数据

yilingjingshui 2013-07-05 11:06:34
网页中有这样一个table
<table style=" height:100%;table-layout:fixed;word-break: break-all" class="QUERYGRID" id="datagrid"><tbody><tr></tr></tbody></table>

如何用一下方法获取
string Pattern2 = @"<table id=""datagrid"".*?</table>";
MatchCollection Matches2 = Regex.Matches(strResult, Pattern2);
...全文
252 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yilingjingshui 2013-07-05
  • 打赏
  • 举报
回复
2位老大分给你们 平分了
yilingjingshui 2013-07-05
  • 打赏
  • 举报
回复
呵呵 你太厉害了 搞定了谢谢
EnForGrass 2013-07-05
  • 打赏
  • 举报
回复
一个匹配用Regex.Match 多个匹配用Regex.Matches (?is)<table[^>]*?id=""datagrid""[^>]*?>.*?</table> string Pattern2 = @"(?is)<table[^>]*?id=""datagrid""[^>]*?>.*?</table>"; Match Matches2 = Regex.Match(strResult, Pattern2); Console.WriteLine(Matches2.Value);
  • 打赏
  • 举报
回复
试试 (?i)<table[^>]*?id=(['""]?)datagrid\1[^>]*?>[\s\S]*?</table>

110,534

社区成员

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

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

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