php preg_match找到没有特定域名的网址

问题描述:

I can get the all images's url in this case.

$str='<img src="http://facebook.com/img1.gif" /><img src="http://yahoo.com/img2.png" /><img src="http://google.com/img3.jpg" />';
preg_match_all('/<img src=(.*)\>/U', $str, $match);

but if i want to get the url without "http://google.com" how can i edit this code? like this:

"http://facebook.com/img1.gif"
"http://yahoo.com/img2.png"

Thank you very much.

you can use this code

    $str='<img src="http://facebook.com/img1.gif" /><img src="http://yahoo.com/img2.png" /><img src="http://google.com/img3.jpg" />';
    echo "<pre>";
      preg_match_all('/<img(.*)src(.*)=(.*)"(.*)"/U', $str, $result);
  print_r($result[4]);

this may be help you, i knw this way is not a correct way