Posted By

slimITTN on 02/11/13


url video id YouTube

Versions (?)

Youtube ID from URL

 / Published in: JavaScript


This snippets show how to extract the video id of a youtube video from its URL

  1. var regExp = /^.*(\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/;
  2. var match = url.match(regExp);
  3. if (match&&match[2].length==11){
  4. return match[2];
  5. }else{
  6. //error
  7. }

Report this snippet  

You need to login to post a comment.