最完美的匹配网页中图片 src 部分的正则表达式

$str='<p style="padding: 0px; margin-top: 0px; margin-bottom: 0px; line-height: 200%;"><img border="0" src="upfiles/2009/07/1246430143_4.jpg" alt=""/></p><p style="padding: 0px; margin-top: 0px; margin-bottom: 0px; line-height: 200%;"><img border="0" src=\'upfiles/2009/07/1246430143_3.jpg\' alt=""/></p><p style="padding: 0px; margin-top: 0px; margin-bottom: 0px; line-height: 200%;"><img border="0" src="upfiles/2009/07/1246430143_1.jpg" alt=""/><img width="280" height="187" alt="" class="imgloading" original="http://s.yoututuan.com/team/2011/1206/13231497847660.jpg" src="http://s.yoututuan.com/team/2011/1206/13231497847660.jpg" style="display: block; ">';
 
    $pattern="/<img.*?src=['|\"](.*?(?:\.(?:gif|jpg)))['|\"].*?[\/]?>/i";
    preg_match_all($pattern,$str,$match);
    
    echo '<pre>';
    print_r($match);

 

posted @ 2015-07-13 15:34  壁虎漫步.  阅读(1585)  评论(0编辑  收藏  举报