Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Extracting ID from Vimeo URL using JavaScript

Posted on 2014-01-11
4
Medium Priority
?
1,026 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 82

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 82

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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

715 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