求正则表达式 替换字符串中的 width="325325" 为 width="216"的正则表达式 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $str='width="325325"';preg_replace("(\d+)", "216", $str);或者$str='width="325325"';str_replace("325325", "216", $str); :) 不是这个意思我要用preg_replace替换已知字符串中所有的width="????" 为width="216" 写成这样,但是不对!不知道原因$str=preg_replace('(width=\"*\")','width="260"',$str) $str=preg_replace('(width=\"\d+\")','width="260"',$str); $str=preg_replace('(width=\"\d+\")','width="260"',$str);不行啊,运行了,没有匹配到 我试过,完全可以$str='wqdqw qdqwdqd width="325325" qwdqwdqwdqw';$str=preg_replace('(width=\"\d+\")','width="260"',$str);echo $str;要不你把你整个$str贴出来我看看 测试例子,没有成功.$str='<align="middle" height="360" width="480">';$str=preg_replace('(width=\"\d+\")','width="260"',$str); 可是...明明成功了呀...$str=' <align="middle" height="360" width="480">';$str=preg_replace('(width=\"\d+\")','width="260"',$str);echo htmlspecialchars($str); 或者不用htmlspecialchars, 直接查看源代码也行,确实是成功了. 那就奇怪了,我是在帝国cms里面写的bqr[newstext]中含有width="480"<?$str=preg_replace('(width=\"\d+\")','width="260"',$bqr[newstext]);$str=preg_replace('(height=\"\d+\")','height="216"',$str);?><?=$str?>一直没有成功 <object class="OBJECT" id="MediaPlayer" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" width="480" height="360" align="middle"><param name="AUTOSTART" value="false" /><param name="ShowStatusBar" value="-1" /><param name="Filename" value="/d/file/shipindianbo/2009-10-15/64a2790d9392db0fe4fc24206af3205b.wmv" /><embed width="480" height="360" type="application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" src="/d/file/shipindianbo/2009-10-15/64a2790d9392db0fe4fc24206af3205b.wmv" flename="mp"></embed></object> 这我就不清楚了``那个$bqr[newstext]是不是需要转换一下字符格式之类的? 直接$str='<object class="OBJECT" id="MediaPlayer" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" width="480" height="360" align="middle"><param name="AUTOSTART" value="false" /><param name="ShowStatusBar" value="-1" /><param name="Filename" value="/d/file/shipindianbo/2009-10-15/64a2790d9392db0fe4fc24206af3205b.wmv" /> <embed width="480" height="360" type="application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" src="/d/file/shipindianbo/2009-10-15/64a2790d9392db0fe4fc24206af3205b.wmv" flename="mp"> </embed> </object>';$str=preg_replace('(width=\"\d+\")','width="200"',$str);echo htmlspecialchars($str); 都是可以的... 郁闷,单独写个test确实是替换了,在帝国里就是木有替换!!!!!!!!!!<?$str='<object class="OBJECT" id="MediaPlayer" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" width="480" height="360" align="middle"> <param name="AUTOSTART" value="false" /> <param name="ShowStatusBar" value="-1" /> <param name="Filename" value="/d/file/shipindianbo/2009-10-15/64a2790d9392db0fe4fc24206af3205b.wmv" /> <embed width="480" height="360" type="application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" src="/d/file/shipindianbo/2009-10-15/64a2790d9392db0fe4fc24206af3205b.wmv" flename="mp"> </embed> </object>';$str=preg_replace('(width=\"\d+\")','width="260"',$str);$str=preg_replace('(height=\"\d+\")','height="216"',$str);?><?=$str?> 呃..爱莫能助了...把那个$bqr[newstext]转换下行吗?用htmlspecialchars之类的`然后正则`然后再转回来???我也不懂了...祝你好运吧 cookie win2003+iis6+apache2+PHP配置环境问题 phpmailer php表单取值小问题 请分析一下这段代码 linux定时执行url问题,在线等 sql查询去除字段中相同的值 如何實現在線留言 关于页面刷新 毕业设计选的课题是:做个软件缺陷管理系统,但现在发现挺难做下去的,学渣求助大神帮忙,感激不尽! 高手看看,控件捕捉的问题 大家过来帮忙看看我的程序写的有什么问题。。我弄半天了
$str='width="325325"';
preg_replace("(\d+)", "216", $str);
或者$str='width="325325"';
str_replace("325325", "216", $str); :)
我要用preg_replace替换已知字符串中所有的width="????" 为width="216"
$str=preg_replace('(width=\"*\")','width="260"',$str)
不行啊,运行了,没有匹配到
$str='wqdqw qdqwdqd width="325325" qwdqwdqwdqw';
$str=preg_replace('(width=\"\d+\")','width="260"',$str);
echo $str;
要不你把你整个$str贴出来我看看
$str='<align="middle" height="360" width="480">';
$str=preg_replace('(width=\"\d+\")','width="260"',$str);
$str=' <align="middle" height="360" width="480">';
$str=preg_replace('(width=\"\d+\")','width="260"',$str);
echo htmlspecialchars($str);
<?
$str=preg_replace('(width=\"\d+\")','width="260"',$bqr[newstext]);
$str=preg_replace('(height=\"\d+\")','height="216"',$str);
?>
<?=$str?>
一直没有成功
<param name="AUTOSTART" value="false" />
<param name="ShowStatusBar" value="-1" />
<param name="Filename" value="/d/file/shipindianbo/2009-10-15/64a2790d9392db0fe4fc24206af3205b.wmv" /><embed width="480" height="360" type="application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" src="/d/file/shipindianbo/2009-10-15/64a2790d9392db0fe4fc24206af3205b.wmv" flename="mp"></embed></object>
$str='<object class="OBJECT" id="MediaPlayer" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" width="480" height="360" align="middle">
<param name="AUTOSTART" value="false" />
<param name="ShowStatusBar" value="-1" />
<param name="Filename" value="/d/file/shipindianbo/2009-10-15/64a2790d9392db0fe4fc24206af3205b.wmv" /> <embed width="480" height="360" type="application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" src="/d/file/shipindianbo/2009-10-15/64a2790d9392db0fe4fc24206af3205b.wmv" flename="mp"> </embed> </object>';$str=preg_replace('(width=\"\d+\")','width="200"',$str);
echo htmlspecialchars($str);
都是可以的...
<?
$str='<object class="OBJECT" id="MediaPlayer" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" width="480" height="360" align="middle">
<param name="AUTOSTART" value="false" />
<param name="ShowStatusBar" value="-1" />
<param name="Filename" value="/d/file/shipindianbo/2009-10-15/64a2790d9392db0fe4fc24206af3205b.wmv" /> <embed width="480" height="360" type="application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" src="/d/file/shipindianbo/2009-10-15/64a2790d9392db0fe4fc24206af3205b.wmv" flename="mp"> </embed> </object>';
$str=preg_replace('(width=\"\d+\")','width="260"',$str);
$str=preg_replace('(height=\"\d+\")','height="216"',$str);
?>
<?=$str?>