Search code examples
androidvimeo

How to extract the video ID from a Vimeo URL in Android


I have the following URL. How to extract the id '4954868' in Android?

"https://vimeo.com/4954868"

Solution

  • Not sure if you are looking for an answer in Kotlin or in Java. This is the Java version:

    String videoUrl = "https://vimeo.com/4954868";
    String id = videoUrl.substring(videoUrl.lastIndexOf("/") + 1, videoUrl.length());