Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This regex grabs the ID from all of the various URLs I could find... There may be more out there, but I couldn't find reference of them anywhere. If you come across one this doesn't match, please leave a comment with the URL, and I'll try and update the regex to match your URL.</p> <pre><code>if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&amp;]v=)|youtu\.be/)([^"&amp;?/ ]{11})%i', $url, $match)) { $video_id = $match[1]; } </code></pre> <p>Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)</p> <ul> <li><a href="http://youtu.be/dQw4w9WgXcQ" rel="noreferrer">http://youtu.be/dQw4w9WgXcQ</a> ...</li> <li><a href="http://www.youtube.com/embed/dQw4w9WgXcQ" rel="noreferrer">http://www.youtube.com/embed/dQw4w9WgXcQ</a> ...</li> <li><a href="http://www.youtube.com/watch?v=dQw4w9WgXcQ" rel="noreferrer">http://www.youtube.com/watch?v=dQw4w9WgXcQ</a> ...</li> <li><a href="http://www.youtube.com/?v=dQw4w9WgXcQ" rel="noreferrer">http://www.youtube.com/?v=dQw4w9WgXcQ</a> ...</li> <li><a href="http://www.youtube.com/v/dQw4w9WgXcQ" rel="noreferrer">http://www.youtube.com/v/dQw4w9WgXcQ</a> ...</li> <li><a href="http://www.youtube.com/e/dQw4w9WgXcQ" rel="noreferrer">http://www.youtube.com/e/dQw4w9WgXcQ</a> ...</li> <li><a href="http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ" rel="noreferrer">http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ</a> ...</li> <li><a href="http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/0/dQw4w9WgXcQ" rel="noreferrer">http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/0/dQw4w9WgXcQ</a> ...</li> <li><a href="http://www.youtube.com/watch?feature=player_embedded&amp;v=dQw4w9WgXcQ" rel="noreferrer">http://www.youtube.com/watch?feature=player_embedded&amp;v=dQw4w9WgXcQ</a> ...</li> <li><a href="http://www.youtube.com/?feature=player_embedded&amp;v=dQw4w9WgXcQ" rel="noreferrer">http://www.youtube.com/?feature=player_embedded&amp;v=dQw4w9WgXcQ</a> ...</li> </ul> <p>It also works on the youtube-nocookie.com URL with the same above options.</p> <p>It will also pull the ID from the URL in an embed code (both iframe and object tags)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload