Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在src中没有字符串的所有iframe上的PHP正则表达式_Php_Regex_Regex Negation - Fatal编程技术网

在src中没有字符串的所有iframe上的PHP正则表达式

在src中没有字符串的所有iframe上的PHP正则表达式,php,regex,regex-negation,Php,Regex,Regex Negation,我如何通过正则表达式获得所有嵌入在src中没有注释的iframe以在preg替换中使用 当前HTML <iframe src="https://www.youtube.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2FMumsVillage%2Fvideos%2F881603451988373%2F&amp;show_text=0&amp;width=560" frameborder="0" allowf

我如何通过正则表达式获得所有嵌入在src中没有注释的iframe以在preg替换中使用

当前HTML

<iframe src="https://www.youtube.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2FMumsVillage%2Fvideos%2F881603451988373%2F&amp;show_text=0&amp;width=560" frameborder="0" allowfullscreen="" width="560" height="315" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen"></iframe>

    <iframe src="https://www.facebook.com/plugins/comment_embed.php?href=https%3A%2F%2Fwww.facebook.com%2FMumsVillage%2Fvideos%2F881603451988373%2F%3Fcomment_id%3D881663971982321&amp;include_parent=false" frameborder="0" allowfullscreen="" width="560" height="161" frameborder="0" scrolling="no"></iframe>

    <iframe src="https://www.facebook.com/plugins/comment_embed.php?href=https%3A%2F%2Fwww.facebook.com%2FMumsVillage%2Fvideos%2F881603451988373%2F%3Fcomment_id%3D881633751985343&amp;include_parent=false" frameborder="0" allowfullscreen="" width="560" height="141" frameborder="0" scrolling="no"></iframe>

    <iframe src="https://www.youtube.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2FMumsVillage%2Fvideos%2F881603451988373%2F&amp;show_text=0&amp;width=560" frameborder="0" allowfullscreen="" width="560" height="315" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen"></iframe>

当前正则表达式

    <iframe[^>]+src="(?!(?:.+ )?comment_embed(?: .+)?")([^"]+)"/isg
]+src=“(?!(?:.+)?注释嵌入(?:+)?”([^“]+)”/isg
试试这个正则表达式:

<iframe ((?!comment_embed).)*?<\/iframe>

非常感谢,这很有效。我如何在preg_replace中使用它来将一个div包装在其他div周围?我不知道你在想什么,但是如果你打算用regex replace进行任何DOM操作,那么算了吧,我退出了。如果要操作HTML文档,应该使用DOM解析器。