Check if the string contains a valid Vimeo URL using JavaScript

In this article, we will show you how to check if the string contains a valid Vimeo URL using JavaScript.

We will also try to get more information from the URL such as video id, thumb image, author name, duration, description, etc.

Here we will discuss the two different ways to check the vimeo URL.

Ways to check the vimeo URL in JavaScript

  1. Using regular expression
  2. Using oEmbed API

1. Using regular expression

Use the following Regular Expression to check the vimeo URL.

2. Using oEmbed API

Don’t rely on Regex as Vimeo tends to change/update its URL pattern every now and then. Instead of the regular expression, we can use the oEmbed API to check the validity and get the video information.

In the following code, we will call an API to get the data.

I hope you find this article helpful.
Thank you for reading. Happy Coding..!! 🙂

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *