C#(正则表达式数据筛选)

I永超 2013-07-24 03:57:05
<div class="clearfix _42ef"><div class="_6a rfloat"><div class="_6a _6b" style="height:50px"></div><div class="_6a _6b"><span class="_52m- _3lt"><a class="hidden_elem uiButton" href="#" role="button" ajaxify="/ajax/follow/follow_profile.php?profile_id=100003717698520&location=4" rel="async-post" id="u_0_2g"><i class="mrs img sp_at8kd9 sx_dedf3e"></i><span class="uiButtonText">关注</span></a><label class="profileFollowButton _52nf _3spg uiButton" id="u_0_2h" for="u_0_2j"><i class="mrs img sp_at8kd9 sx_d4ea38"></i><input value="关注" aria-haspopup="1" data-profileid="100003717698520" type="submit" id="u_0_2j" /></label></span></div></div><div class="uiProfileBlockContent"><div class="_6a"><div class="_6a _6b" style="height:50px"></div><div class="_6a _6b"><div><span class="fsl fwb fcb"><a href="https://www.facebook.com/karma.dawa.7?fref=st" data-hovercard="/ajax/hovercard/user.php?id=100003717698520">杜汶澤 <span class="alternate_name">(Karma Dawa)</span></a></span> <div class="inlineBlock"><span class="fsm fwn fcg">· 307,993 位关注者</span></div></div><ul class="uiList _4kg"><li><span class="_50hf fsm fwn">在 <a class="uiLinkSubtle" href="https://www.facebook.com/pages/EEG-%E8%8B%B1%E7%9A%87%E5%A8%9B%E6%A8%82/190788624279794">EEG (英皇娛樂)</a> 任 <a class="uiLinkSubtle" href="https://www.facebook.com/pages/ProducerArtist/143848955644597">Producer/Artist</a></span></li></ul></div></div></div></div></div></li><li class="followListItem fbProfileBrowserListItem"><div class="clearfix"><a class="_8o _8t lfloat" href="https://www.facebook.com/holaam?fref=pb" tabindex="-1" aria-hidden="true"><img class="_s0 _rw img" src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/623959_1231987616_2122202226_q.jpg" alt="" /></a><div class="clearfix _42ef"><div class="_6a rfloat"><div class="_6a _6b" style="height:50px"></div><div class="_6a _6b"><span class="_52m- _3lt"><a class="hidden_elem uiButton" href="#" role="button" ajaxify="/ajax/follow/follow_profile.php?profile_id=1231987616&location=4" rel="async-post" id="u_0_2c"><i class="mrs img sp_at8kd9 sx_dedf3e"></i><span class="uiButtonText">关注</span></a><label class="profileFollowButton _52nf _3spg uiButton" id="u_0_2d" for="u_0_2f"><i class="mrs img sp_at8kd9 sx_d4ea38"></i><input value="关注" aria-haspopup="1" data-profileid="1231987616" type="submit" id="u_0_2f" /></label></span></div></div><div class="uiProfileBlockContent"><div class="_6a"><div class="_6a _6b" style="height:50px"></div><div class="_6a _6b"><div><span class="fsl fwb fcb"><a href="https://www.facebook.com/holaam?fref=st" data-hovercard="/ajax/hovercard/user.php?id=1231987616">Jackie Fung</a></span> <div class="inlineBlock"><span class="fsm fwn fcg"> · 朋友请求已送出</span><span class="fsm fwn fcg">· 33 位关注者</span></div></div><ul class="uiList _4kg"><li><span class="_50hf fsm fwn"><a class="uiLinkSubtle" href="https://www.facebook.com/pages/Hong-Kong/113317605345751">Hong Kong</a></span></li></ul></div></div></div></div></div></li><li class="followListItem fbProfileBrowserListItem"><div class="clearfix"><a class="_8o _8t lfloat" href="https://www.facebook.com/li.sally.96?fref=pb" tabindex="-1" aria-hidden="true"><img class="_s0 _rw img" src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/370802_100003238374636_486819783_q.jpg" alt="" /></a><div class="clearfix _42ef"><div class="_6a rfloat"><div class="_6a _6b" style="height:50px"></div><div class="_6a _6b"><span class="_52m- _3lt"><a class="hidden_elem uiButton" href="#" role="button" ajaxify="/ajax/follow/follow_profile.php?profile_id=100003238374636&location=4" rel="async-post" id="u_0_28"><i class="mrs img sp_at8kd9 sx_dedf3e"></i><span class="uiButtonText">关注</span></a><label class="profileFollowButton _52nf _3spg uiButton" id="u_0_29" for="u_0_2b"><i class="mrs img sp_at8kd9 sx_d4ea38"></i><input value="关注" aria-haspopup="1" data-profileid="100003238374636" type="submit" id="u_0_2b" /></label></span></div></div><div class="uiProfileBlockContent"><div class="_6a"><div class="_6a _6b" style="height:50px"></div><div class="_6a _6b"><div><span class="fsl fwb fcb"><a href="https://www.facebook.com/li.sally.96?fref=st" data-hovercard="/ajax/hovercard/user.php?id=100003238374636">肖丽</a></span> <div class="inlineBlock"><span class="fsm fwn fcg"> · 朋友请求已送出</span><span class="fsm fwn fcg">· 33 位关注者</span></div>

大家看我这一段HTML源码,我要从中筛选到所有模块id为100003717698520的值,求正则表达式怎么写呀?
...全文
232 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
屌絲來襲 2013-07-26
  • 打赏
  • 举报
回复
錯了,改一下
id=(?<id>\d*?)">(?<name>.*?)<

屌絲來襲 2013-07-26
  • 打赏
  • 举报
回复
屌絲來襲 2013-07-26
  • 打赏
  • 举报
回复
id=\d(?<id>.*?)">(?<name>.*?)<
shawn_yang 2013-07-25
  • 打赏
  • 举报
回复
new Regex(@"(?i)(?<=<a.*?id=\d+"">)(.*?)(?=<)", RegexOptions.ExplicitCapture)
I永超 2013-07-24
  • 打赏
  • 举报
回复
怎么不对呢?
I永超 2013-07-24
  • 打赏
  • 举报
回复
I永超 2013-07-24
  • 打赏
  • 举报
回复

这样写不对呀???
shawn_yang 2013-07-24
  • 打赏
  • 举报
回复
(?i)(?<=<a.*?id=\d+">)(.*?)(?=<) 你少个引号
I永超 2013-07-24
  • 打赏
  • 举报
回复

怎么筛选不到呀???
shawn_yang 2013-07-24
  • 打赏
  • 举报
回复
(?i)(?<=<a.*?id=\d+">)(.*?)(?=<)
shawn_yang 2013-07-24
  • 打赏
  • 举报
回复
引用 3 楼 shawn_yang 的回复:
(?i)(?<=<a.*?id=100003717698520">)(.*?)(?=<)
大家看我这一段HTML源码,我要从中筛选到所有模块id为100003717698520的值,求正则表达式怎么写呀?
I永超 2013-07-24
  • 打赏
  • 举报
回复
我不是只要这一个id值,下面的id=100003238374636">肖丽,id值也要阿
shawn_yang 2013-07-24
  • 打赏
  • 举报
回复
(?i)(?<=<a.*?id=100003717698520">)(.*?)(?=<)
  • 打赏
  • 举报
回复
你发了这么多正则表达式的数据筛选,为什么不正儿八经去学一个html解析库呢? http://htmlagilitypack.codeplex.com/ http://zhoufoxcn.blog.51cto.com/792419/595344
I永超 2013-07-24
  • 打赏
  • 举报
回复

110,534

社区成员

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

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

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