Yes I have a same problem few months ago and I have made this function to get video id for youtube and Vimeo..
Here is your Solution..
function Getvideoid(videolink)
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var match = videolink.match(regExp);
if (match && match[7].length == 11)
{
alert("youtube video id : "+ match[7]);
return;
}
regExp = "vimeo\\.com/(?:.*#|.*/videos/)?([0-9]+)";
match = videolink.match(regExp);
if(match)
{
var videoid = videolink.split('/')[videolink.split('/').length - 1];
alert("vimeo video id :"+videoid);
}
else
{
alert("Unknown url");
}
and here is JSBIN Link http://jsbin.com/zoxicoko/2/