Youtube和Vevo视频有任何正则表达式吗?Youtube或Vevo的正则表达式
下面是一些示例代码: 的Youtube:CevxZvSJLk8 VEVO:USUV71402382
据我所知,该模式似乎对YouTube视频小写字母。如何使用正则表达式正确检测它们?
只是为了说清楚,这里是我的问题:
- 什么是针对YouTube代码的权力正则表达式模式?
- 什么是Vevo代码的正确的正则表达式 模式?
我试图把代码的URL的最后一部分: VEVO:http://cache.vevo.com/assets/html/embed.html?video=USUV70904460 的Youtube:http://www.youtube.com/embed/P1j-6vRykFs
的代码看起来就像这样:
function get_video_url($video_code) {
if (preg_match_all('<Youtube regex code>',$video_code)) {
return "http://www.youtube.com/embed/" . $code;
} elseif (preg_match_all('<Vevo regex code>',$video_code)) {
return "http://cache.vevo.com/assets/html/embed.html?video=" . $code;
} else {
return "Youtube or vevo link anyway.";
}
}
我只是不过,需要正则表达式。
你从哪里得到的代码?是否有可能只检查域名? – 2014-12-04 03:09:17
不可以,因为用户只会单独发布视频代码。 – 2014-12-04 04:02:27
对于vevo,如果这是模式,那么它的[a-zA-Z] {4} \ d {8} – argentum47 2014-12-04 04:33:53