Php 正则表达式匹配vimeo嵌入url中的所有域和视频ID
我想从下面的内容中获取dailymotion视频url和视频id的多个匹配项Php 正则表达式匹配vimeo嵌入url中的所有域和视频ID,php,regex,Php,Regex,我想从下面的内容中获取dailymotion视频url和视频id的多个匹配项 <iframe style="clear: both; display: block;" src="//www.dailymotion.com/embed/video/x1a6ldm" height="315" width="420" allowfullscreen="" frameborder="0"></iframe> <iframe style="clear: both; dis
<iframe style="clear: both; display: block;"
src="//www.dailymotion.com/embed/video/x1a6ldm"
height="315" width="420" allowfullscreen="" frameborder="0"></iframe>
<iframe style="clear: both; display: block;"
src="//www.dailymotion.com/embed/video/x1a6k8x"
height="315" width="420" allowfullscreen="" frameborder="0"></iframe>
<iframe style="clear: both; display: block;"
src="//www.dailymotion.com/embed/video/x1a6k1i"
height="315" width="420" allowfullscreen="" frameborder="0"></iframe>
我还尝试了有关stackoverflow的最大问题,但没有找到任何解决方案。我对正则表达式非常陌生
我正在测试它下面的正则表达式似乎工作正常
(www\.dailymotion.com\/embed\/video\/.*?)"
基于代码使用情况的示例:
preg_match_all ('(www\.dailymotion.com\/embed\/video\/.*?)"', $content, $dailymotionmatches, PREG_SET_ORDER);
更新
要获取视频id本身,请使用以下正则表达式
(www\.dailymotion.com/embed/video/(.*?))"
preg_match_all ('(www\.dailymotion.com\/embed\/video\/.*?)"', $content, $dailymotionmatches, PREG_SET_ORDER);
视频id将作为一个数组出现在结果位置2。提取链接。使用正则表达式测试url。您也可以使用。@tenub谢谢您的建议,但我需要regax<代码>*dailymotion\.com\/embed\/video\/[a-z0-9]+
(www\.dailymotion.com/embed/video/(.*?))"
preg_match_all ('(www\.dailymotion.com\/embed\/video\/.*?)"', $content, $dailymotionmatches, PREG_SET_ORDER);