问题:
使用正则表达式
我需要确认IFRAME有下列格式中的一个类型的链接:
http://www.example.com/embed/*****11 CHARACTERS MAX.****?rel=0
Starts with: http://www.example.com/embed/
Ends with: ?rel=0
11 CHARACTERS MAX. means in this spot, there can any 11 characters. Don't go beyond 11.
注:没有指定的标签确保在每一篇文章中。这取决于用户如何使用编辑器。
我使用PHP
我用下面的线,以确保所有的标签都排除在外,除了指定的那些:
$rtxt_offer = preg_replace('#<(?!/?(u|br|iframe)\b)[^>]+>#', '', $rtxt_offer);
请参阅:[在PHP中提取HTML中的所有文本和img标记。](http://stackoverflow.com/q/8021543/367456)(已关闭)。 – hakre
[用PHP解析HTML的最佳方法]的可能重复(http://stackoverflow.com/questions/3577641/best-methods-to-parse-html-with-php) - 要点:考虑不要使用正则表达式解析HTML。 – hakre
我忘了修复我的标题。 – user311509