php正则表达式替换问题php函数preg_replace的使用问题 50
<divclass="pic-list"><ul><li><divclass="pic-list-con"><atarget="_blank"href="/d/f_pla...
<div class="pic-list">
<ul>
<li>
<div class="pic-list-con"><a target="_blank" href="/d/f_players/4/3033/">
<img alt="卡希尔" src="http://img1.gtimg.com/dbimg/2011/mainpiclib/20110415/15/bb1b2442879b4d4d5bba358b8723b8cf4.jpg">
</a></div><p><a style="cursor:hand;" target="_blank" href="/d/f_players/4/3033/">卡希尔</a></p>
</li>
<li>
<div class="pic-list-con"><a target="_blank" href="/d/f_players/4/3327/">
<img alt="卡库塔" src="http://img1.gtimg.com/dbimg/2011/mainpiclib/20110414/09/3d7c2dcd64a17eac4a395be7b8bee7024.jpg">
</a></div><p><a style="cursor:hand;" target="_blank" href="/d/f_players/4/3327/">卡库塔</a></p>
</li>
<li>
<div class="pic-list-con"><a target="_blank" href="/d/f_players/4/3953/">
<img alt="阿扎尔" src="http://img1.gtimg.com/dbimg/2011/mainpiclib/20110414/23/7bcf5c911073bfdf44bb91417ab3f9ca4.jpg">
</a></div><p><a style="cursor:hand;" target="_blank" href="/d/f_players/4/3953/">阿扎尔</a></p>
</li>
</ul>
</div>
我想吧以上代码替换为空。简单点来说就是我要从<div class="pic-list">开始替换到与他匹配的</div>问题不清楚的可以追问 展开
<ul>
<li>
<div class="pic-list-con"><a target="_blank" href="/d/f_players/4/3033/">
<img alt="卡希尔" src="http://img1.gtimg.com/dbimg/2011/mainpiclib/20110415/15/bb1b2442879b4d4d5bba358b8723b8cf4.jpg">
</a></div><p><a style="cursor:hand;" target="_blank" href="/d/f_players/4/3033/">卡希尔</a></p>
</li>
<li>
<div class="pic-list-con"><a target="_blank" href="/d/f_players/4/3327/">
<img alt="卡库塔" src="http://img1.gtimg.com/dbimg/2011/mainpiclib/20110414/09/3d7c2dcd64a17eac4a395be7b8bee7024.jpg">
</a></div><p><a style="cursor:hand;" target="_blank" href="/d/f_players/4/3327/">卡库塔</a></p>
</li>
<li>
<div class="pic-list-con"><a target="_blank" href="/d/f_players/4/3953/">
<img alt="阿扎尔" src="http://img1.gtimg.com/dbimg/2011/mainpiclib/20110414/23/7bcf5c911073bfdf44bb91417ab3f9ca4.jpg">
</a></div><p><a style="cursor:hand;" target="_blank" href="/d/f_players/4/3953/">阿扎尔</a></p>
</li>
</ul>
</div>
我想吧以上代码替换为空。简单点来说就是我要从<div class="pic-list">开始替换到与他匹配的</div>问题不清楚的可以追问 展开
2个回答
展开全部
都帮你测试好了,正则多写一个<ul>就能搞定了:
<?php
$str = '你的一大堆字符串'; // 你如果直接放字符串,需要用单引号
$reg = '/<div class="pic-list">\s+<ul>.*?<\/ul>\s+<\/div>/is';
$new_str = preg_replace( $reg, '', $str);
echo $new_str;
?>
<?php
$str = '你的一大堆字符串'; // 你如果直接放字符串,需要用单引号
$reg = '/<div class="pic-list">\s+<ul>.*?<\/ul>\s+<\/div>/is';
$new_str = preg_replace( $reg, '', $str);
echo $new_str;
?>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询