- UID
- 228521
- 帖子
- 8
- 精华
- 0
- 贡献
- 0
- 推广
- 0
- 有效BUG
- 0
- 注册时间
- 2009-9-5
|
现有网页源文件片段如下:
-
- <div class="q_ht">
- <div class="q_ht1"> <a href="topic.php?gid=1414&tid=14838260" class="sl f14" title="加群15651783就送50个金典奶">加群15651783就送50个金典奶</a> </div>
- <div class="q_ht2 c6">146</div>
- <div class="q_ht3 c6">21</div>
- <div class="q_ht4"><a href="/home/?uid=15547201" class="sl" title="张凤颂"><img src="http://pic1.kaixin001.com/logo/54/72/20_15547201_1.jpg" width="20" height="20" align="absmiddle" /></a> <a href="/home/?uid=15547201" class="sl" title="张凤颂">张凤颂</a></div>
- <div class="l c6">18:41</div>
- <div class="c"></div>
- </div>
- <div class="q_ht">
- <div class="q_ht1"> <a href="topic.php?gid=1414&tid=14845882" class="sl f14" title="加我一起玩啊~">加我一起玩啊~</a> </div>
- <div class="q_ht2 c6">18</div>
- <div class="q_ht3 c6">1</div>
- <div class="q_ht4"><a href="/home/?uid=44059996" class="sl" title="王钰洁"><img src="http://pic.kaixin001.com/logo/5/99/20_44059996_1.jpg" width="20" height="20" align="absmiddle" /></a> <a href="/home/?uid=44059996" class="sl" title="王钰洁">王钰洁</a></div>
- <div class="l c6">18:33</div>
- <div class="c"></div>
- </div>
- <div class="q_ht">
- <div class="q_ht1"> <a href="topic.php?gid=1414&tid=14736950" class="sl f14" title="手机短信媳妇随时看">手机短信媳妇随时看</a> </div>
- <div class="q_ht2 c6">166</div>
- <div class="q_ht3 c6">16</div>
- <div class="q_ht4"><a href="/home/?uid=50473948" class="sl" title="李征鹏(ZP)"><img src="http://pic.kaixin001.com/logo/47/39/20_50473948_2.jpg" width="20" height="20" align="absmiddle" /></a> <a href="/home/?uid=50473948" class="sl" title="李征鹏(ZP)">李征鹏(ZP)</a></div>
- <div class="l c6">18:29</div>
- <div class="c"></div>
- </div>
复制代码
我想将第二个外层div标签内的内容全部屏蔽为
<div class="q_ht">已过滤</div>
过滤条件是内层中第四个div中的uid——44059996
<div class="q_ht4"><a href="/home/?uid=44059996" class="sl" title="王钰洁"><img src="http://pic.kaixin001.com/logo/5/99/20_44059996_1.jpg" width="20" height="20" align="absmiddle" /></a> <a href="/home/?uid=44059996" class="sl" title="王钰洁">王钰洁</a></div>
也就是说,只要第四个div的链接中含有uid 44059996,我就要将整个外层div标签的内容屏蔽
请问我应该怎么做?
我自己写的:
(<div class=\"q_htq\">[^<]*?(<div[^>]*?>[\s\S]*?<\/div>[^<]*?){3}<div class=\"q_htq4\"><a href=\"\/home\/\?uid=44059996\"[\s\S]*?<\/a>[\s\S]*?(?:<div[\s\S]*?<\/div>[\s\S]*?){2}[\s\S]*?<\/div>)
会将外层第一个div下的东西也过滤掉…… |
|