一个正则替换问题 本帖最后由 wpost 于 2010-03-18 22:19:16 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php $str='<div style="background:#EFF2FA;overflow:hidden;padding:0 3px;line-height:29px;height:30px;word-break:normal;">adfadfadfadfadfadad</div>';echo preg_replace("/\<div.+?\>(.*?)\<\/div\>/","123456",$str);?> <?php $str='<div style="background:#EFF2FA;overflow:hidden;padding:0 3px;line-height:29px;height:30px;word-break:normal;">adfadfadfadfadfadad</div>';echo htmlspecialchars(preg_replace("/(\<div.+?\>)(.*?)(\<\/div\>)/","\${1}123456\${3}",$str));//<div style="background:#EFF2FA;overflow:hidden;padding:0 3px;line-height:29px;height:30px;word-break:normal;">123456</div>?> 楼上的先谢谢了。不过我的意思是前面 后面有好多的DIV 但是就这个<div style="background:#EFF2FA;overflow:hidden;padding:0 3px;line-height:29px;height:30px;word-break:normal;">是一个唯一 ,这个该如何写正则? 数组中 php 中文键名的事情 php服务器是linux的话,有没有办法读取word的内容? 如何得到fwrite将内容写入文件所花的时间 thinkphp 处理大批量数据 如何在IE当中显示链接,求救!!! 关于表格的显示问题 怎么将地址栏的URL 加密? 很有诱惑力呦 To孟子E章,为什么我用mail()函数不能发比较大的信呢? 请问如何在javascript中实现PHP中的chr函数功能啊 用数据库存储图像的问题? include virtual= 为什么显示啊
$str='<div style="background:#EFF2FA;overflow:hidden;padding:0 3px;line-height:29px;height:30px;word-break:normal;">adfadfadfadfadfadad</div>';
echo preg_replace("/\<div.+?\>(.*?)\<\/div\>/","123456",$str);
?>
$str='<div style="background:#EFF2FA;overflow:hidden;padding:0 3px;line-height:29px;height:30px;word-break:normal;">adfadfadfadfadfadad</div>';
echo htmlspecialchars(preg_replace("/(\<div.+?\>)(.*?)(\<\/div\>)/","\${1}123456\${3}",$str));//<div style="background:#EFF2FA;overflow:hidden;padding:0 3px;line-height:29px;height:30px;word-break:normal;">123456</div>
?>
前面 后面有好多的DIV 但是就这个
<div style="background:#EFF2FA;overflow:hidden;padding:0 3px;line-height:29px;height:30px;word-break:normal;">
是一个唯一 ,这个该如何写正则?