结合两个正则表达式preg_match_all搜索

时间:2017-05-25 08:11:54

标签: php regex

我是普通级别的PHP程序员,我试图从我的html内容中抓取所有图片和iframe,但我设法超出了我的能力水平!

我有两个不同的调用,它们都独立工作:

function get_the_images($content) {

     //$matches will be an array with all images
     preg_match_all("/<img[^>]+\>/i", $content, $matches);
     return $matches;

}

function get_the_iframes($content) {

     //$matches will be an array with all iframes
     preg_match_all('#(?:<iframe[^>]*)(?:(?:/>)|(?:>.*?</iframe>))#i', $content, $matches);
     return $matches;

}

我想要做的是将这些2组合成一个单一的preg_match_all搜索。任何人都可以帮我把两者结合起来吗?

提前感谢您的帮助!

0 个答案:

没有答案
相关问题