Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
182
rated 0 times [  185] [ 3]  / answers: 1 / hits: 24383  / 14 Years ago, wed, may 26, 2010, 12:00:00

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.


More From » vimeo

 Answers
13

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);
}

[#96676] Monday, May 24, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
devlin

Total Points: 474
Total Questions: 113
Total Answers: 100

Location: Sweden
Member since Fri, Apr 16, 2021
3 Years ago
;