How do I parse an ID from a Vimeo URL in JavaScript?
The URL will be entered by a user, so I will need to check that they have entered it in the correct format.
I need the ID so that I can use their simple API to retrieve video data.
As URLs for Vimeo videos are made up by http://vimeo.com/
followed by the numeric id, you could do the following
var url = "http://www.vimeo.com/7058755";
var regExp = /http:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;
var match = url.match(regExp);
if (match){
alert("id: " + match[2]);
}
else{
alert("not a vimeo url");
}