Link to home
Start Free TrialLog in
Avatar of ivanblue
ivanblueFlag for United States of America

asked on

Extracting ID from Vimeo URL using JavaScript

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.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ivanblue

ASKER

It works perfectly! Can you please explain how this works?
Thanks so much!
Did you check the link provided?
Yes, now I did. Thanks leakim971!