$html = “……”;
$preg = “/<[img|IMG].*?src=[\’|\”](.*?(?:[\.gif|\.jpg]))[\’|\”].*?[\/]?>/i”;
preg_match_all($preg , $html , $matches);
print_r($matches[1]);
exit;
匹配图片和url的正则,返回数组
$matches[0] = 是完整的图片标签
$matches[1] = 是url
二皮博客
能根据所给html内容,获取其中包含的所有的图片url的正则
$html = “……”;
$preg = “/<[img|IMG].*?src=[\’|\”](.*?(?:[\.gif|\.jpg]))[\’|\”].*?[\/]?>/i”;
preg_match_all($preg , $html , $matches);
print_r($matches[1]);
exit;
匹配图片和url的正则,返回数组
$matches[0] = 是完整的图片标签
$matches[1] = 是url