Snippet

e.g. if the youtube, video url is:

http://www.youtube.com/watch?v=xptDCPlSSfI&

The snippet will return xptDCPlSSfI

var url = "http://www.youtube.com/watch?v=xptDCPlSSfI";


var video_id = url.split('v=')[1];

var ampersandPosition = video_id.indexOf('&');

if(ampersandPosition != -1)
{

video_id = video_id.substring(0, ampersandPosition);


}