提取字符串中的图片地址[正则表达式]
$oldContent = '<p><img src="//dev.gw.woyaobaoxiu.cn/uploads/ueditor/image/20180911/153662877574057006.jpg" width="622" height="157" style="width: 622px; height: 157px;"></p><p><img src="//dev.gw.woyaobaoxiu.cn/uploads/ueditor/image/20180911/153662989034909057.jpg"></p>';
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpeg|\.png|\.jpg]))[\'|\"].*?[\/]?>/";
preg_match_all($pattern, $oldContent, $match);
print_r($match);
结果显示:
Array
(
[0] => Array
(
[0] =>"
<img src="//dev.gw.woyaobaoxiu.cn/uploads/ueditor/image/20180911/153662877574057006.jpg" width="622" height="157" style="width: 622px; height: 157px;">
"
[1] =>"
<img src="//dev.gw.woyaobaoxiu.cn/uploads/ueditor/image/20180911/153662989034909057.jpg">
"
)
[1] => Array
(
[0] => //dev.gw.woyaobaoxiu.cn/uploads/ueditor/image/20180911/153662877574057006.jpg
[1] => //dev.gw.woyaobaoxiu.cn/uploads/ueditor/image/20180911/153662989034909057.jpg
)
)