Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Extracting ID from Vimeo URL using JavaScript

Posted on 2014-01-11
4
Medium Priority
?
1,060 Views
Last Modified: 2014-01-11
Hello, I'm using this code to extract the ID from a Vimeo URL:

vimeo_id = message.split(/video\/|http:\/\/vimeo\.com\//)[1].split(/[?&]/)[0];

Open in new window

But this code doesn't work when there's https instead of http. How can I make it work with https too? I prefer to keep the split instead of using a regexp if possible.

And how does this code work? Can you explain it?

Thanks.
0
Comment
Question by:ivanblue
  • 2
  • 2
4 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39773272
Add << s? >>  after http

http://www.regular-expressions.info/optional.html

vimeo_id = message.split(/video\/|https?:\/\/vimeo\.com\//)[1].split(/[?&]/)[0];

Open in new window

0
 
LVL 1

Author Comment

by:ivanblue
ID: 39773277
It works perfectly! Can you please explain how this works?
Thanks so much!
0
 
LVL 83

Expert Comment

by:leakim971
ID: 39773283
Did you check the link provided?
0
 
LVL 1

Author Comment

by:ivanblue
ID: 39773781
Yes, now I did. Thanks leakim971!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question