在src中没有字符串的所有iframe上的PHP正则表达式
我如何通过正则表达式获得所有嵌入在src中没有注释的iframe以在preg替换中使用 当前HTML在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&show_text=0&width=560" frameborder="0" allowf
<iframe src="https://www.youtube.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2FMumsVillage%2Fvideos%2F881603451988373%2F&show_text=0&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&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&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&show_text=0&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解析器。