php用正则替换img src的方法:首先打开相应的php文件;然后添加正则内容为“preg_replace('/()/i'...”并保存即可。

推荐:《PHP视频教程》
具体问题:
正文中有多个这样的标签,如下
<img width="197" style="max-width:90%" alt=" " src="/case/clxy/page/files/newspic/20090928084704364888.jpg" border="0" />
我要将其中src中的路径去掉开头的 "/case/clxy/page/"
是要正文中的所有的img标签都是要替换的。
立即学习“PHP免费学习笔记(深入)”;
实现方法:
这个还要写正则! 直接用DW 就可以批量替换了!
帮你写了一个
$url ='<img width="197" style="max-width:90%" alt=" " src="/case/clxy/page/files/newspic/20090928084704364888.jpg" border="0" />';
$ok=preg_replace('/(<img .+src=\"?.+)(case\/clxy\/page\/)(.+\.\"?.+ alt="php怎么用正则替换img中src" >)/i',"\${1}\${3}",$url);
echo $ok;替换后的结果为
<img width="197" style="max-width:90%" alt=" " src="/files/newspic/20090928084704364888.jpg" border="0" />











