Skip to content

Instantly share code, notes, and snippets.

@jpibarra1130
Created April 5, 2014 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpibarra1130/9993586 to your computer and use it in GitHub Desktop.
Save jpibarra1130/9993586 to your computer and use it in GitHub Desktop.
A simple ruby snippet to retrieve the id for a vimeo url.
# Simple ruby snippet to get the id for a vimeo url. This was based on this gist: https://gist.github.com/wwdboer/4943672
# This should be able to handle the following formats:
# http://vimeo.com/12345
# http://player.vimeo.com/video/12345
# http://player.vimeo.com/video/12345?test=value1
# http://player.vimeo.com/video/12345/?test=value1
# http://vimeo.com/channels/testchannel/12345
# http://vimeo.com/groups/testgroup/videos/1234
def vimeo_id(url)
match = url.match(/https?:\/\/(?:[\w]+\.)*vimeo\.com(?:[\/\w]*\/?)?\/(?<id>[0-9]+)[^\s]*/)
match[:id] if match.present?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment