$s =<<< TXT
<p style="text-align: center;">
<img alt="大破推进城 《谁是海盗王》推塔攻略" src="/uploads/allimg/141111/36-141111161304120.jpg" style="width: 500px; height: 387px;" /></p>
  <img alt="大破推进城 《谁是海盗王》推塔攻略" src="/uploads/allimg/141111/36-14111116131b33.jpg" style="width: 500px; height: 410px;" /></p>
<p>
<img alt="大破推进城 《谁是海盗王》推塔攻略" src="/uploads/allimg/141111/36-141111161330532.jpg" style="width: 500px; height: 298px;" /></p>
<p> <img alt="大破推进城 《谁是海盗王》推塔攻略" src="http://www.xx.com/uploads/allimg/141111/36-141111161340F2.png" style="width: 500px; height: 500px;" /></p>
TXT;
echo preg_replace_callback('/(?<=src=")([^"]+)/i', function($m) {
  $p = parse_url($m[1]);
  return 'http://img.xx.com/uploads/alimg/' . basename($p['path']);
}, $s);<p style="text-align: center;">
<img alt="大破推进城 《谁是海盗王》推塔攻略" src="http://img.xx.com/uploads/alimg/36-141111161304120.jpg" style="width: 500px; height: 387px;" /></p>
  <img alt="大破推进城 《谁是海盗王》推塔攻略" src="http://img.xx.com/uploads/alimg/36-14111116131b33.jpg" style="width: 500px; height: 410px;" /></p>
<p>
<img alt="大破推进城 《谁是海盗王》推塔攻略" src="http://img.xx.com/uploads/alimg/36-141111161330532.jpg" style="width: 500px; height: 298px;" /></p>
<p> <img alt="大破推进城 《谁是海盗王》推塔攻略" src="http://img.xx.com/uploads/alimg/36-141111161340F2.png" style="width: 500px; height: 500px;" /></p>

解决方案 »

  1.   

    顶,精简啊
    /(?<=src=")([^"]+)/  =》 /(?<=src=")([^\"]+)/
      

  2.   


    $s=<<<
    <p style="text-align: center;">
    <img alt="大破推进城 《谁是海盗王》推塔攻略" src="/uploads/allimg/141111/36-141111161304120.jpg" style="width: 500px; height: 387px;"/></p>
    <img alt="大破推进城 《谁是海盗王》推塔攻略" src="/uploads/allimg/141111/36-14111116131b33.jpg" style="width: 500px; height: 410px;"/></p>
    <p><img alt="大破推进城 《谁是海盗王》推塔攻略" src="/uploads/allimg/141111/36-141111161330532.jpg" style="width: 500px; height: 298px;"/></p>
    <p><img alt="大破推进城 《谁是海盗王》推塔攻略" src="http://www.xx.com/uploads/allimg/141111/36-141111161340F2.png" style="width: 500px; height: 500px;"/></p>
    ;
    $par='!src="(.*?)"!';
    echo preg_replace_callback($par,'my',$s);
    function my($s){
        $item=pathinfo($s[1]);
        if($item['extension']=='jpg'){
            return "src='http://img.xx.com/uploads/alimg/{$s[1]}'";
        }else{
            return "src='{$s[1]}'";
        }
    }<p style="text-align: center;">
    <img alt="大破推进城 《谁是海盗王》推塔攻略" src='http://img.xx.com/uploads/alimg//uploads/allimg/141111/36-141111161304120.jpg' style="width: 500px; height: 387px;"/></p>
    <img alt="大破推进城 《谁是海盗王》推塔攻略" src='http://img.xx.com/uploads/alimg//uploads/allimg/141111/36-14111116131b33.jpg' style="width: 500px; height: 410px;"/></p>
    <p><img alt="大破推进城 《谁是海盗王》推塔攻略" src='http://img.xx.com/uploads/alimg//uploads/allimg/141111/36-141111161330532.jpg' style="width: 500px; height: 298px;"/></p>
    <p><img alt="大破推进城 《谁是海盗王》推塔攻略" src='http://www.xx.com/uploads/allimg/141111/36-141111161340F2.png' style="width: 500px; height: 500px;"/></p>