DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Slim has posted 1 posts at DZone. View Full User Profile

Extract Youtube Video ID from URL

02.10.2013
| 7755 views |
  • submit to reddit
    /* Source : http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url  */
     
    var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/;
    var match = url.match(regExp);
    if (match&&match[2].length==11){
        return match[2];
    }else{
        //error
    }

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

Comments

Engr Ubaid Masood replied on Mon, 2014/02/03 - 1:16am

Hi,

This is great informative and helpful blog , thanks for sharing

Regards,

construction site security in london

www.royalarmorgroup.com

hire domestic workers in london

www.oliverz.co.uk

 Hire security in london

www.ieventsecurity.co.uk

bodyguard services London

www.ibodyguardlondon.com

 

 


 

Michael Molo replied on Thu, 2013/02/21 - 1:36am