$content = eregi_replace("<img src=\"[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]\">", "\\0\"/>", $text);
$content = str_replace(">\", "", $text);
preg_replace("/<img src=\"(.+?)\">/i", "<img src=\"\$1\"/>", $text);

解决方案 »

  1.   

    你找到 “>”,把它该成“/>”不就完事了吗? 干吗要把前面这一大串整个替换。
      

  2.   

    cgwxyz(cgwxyz):这样显然不行,因为只是想替换img标签的关闭符号
      

  3.   

    <script language=javascript>
    var str='<img src="http://...">' 
    re=/^\<img\s+[^\>]+?(\>)$/i;
    re.test(str)
    str=str.replace(RegExp.$1,"/>");
    alert(str)
    </script>
    js的,你改成php的试试吧
      

  4.   

    $text=preg_replace("/(<img[^<]+)>/","\\1/>",$text);
      

  5.   

    $str='<img src="http://llkll">';
    $re='/^(\<img\s+[^\>]+?)(\>)$/i';
    $replacement="\\1 /\\2";
    echo preg_replace($re,$replacement,$str);