Is there any regex formula for Youtube and Vevo videos?
Here are some sample code: Youtube: CevxZvSJLk8 Vevo: USUV71402382
From what I know, the pattern seems to have small letters for a youtube video. How do I detect them properly using regex?
Just to make it clear, here are my questions:
- What is the right regex pattern for a Youtube code?
- What is the right regex pattern for Vevo code?
I'm trying to put the codes on the last part of the url: Vevo: http://cache.vevo.com/assets/html/embed.html?video=USUV70904460 Youtube: http://www.youtube.com/embed/P1j-6vRykFs
The code will look like this:
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.";
}
}
I just need the regex, though.