I want to get the v=id from YouTube’s URL with JavaScript (no jQuery, pure JavaScript).
v=id
http://www.youtube.c
Try this one -
function getYouTubeIdFromURL($url) { $pattern = '/(?:youtube.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu.be/)([^"&?/ ]{11})/i'; preg_match($pattern, $url, $matches); return isset($matches[1]) ? $matches[1] : false; }