var pathn = document.location.pathname; pathn.match(/(?<=\/video\/)[^/?]+/)[0]; //dailymotion pathn.match(/(?<=\/watch\?v=)[^/?]+)[0]; //youtube pathn.slice(1); //vimeomeo