Question: How to check if the string contains a valid vimeo url using javascript ?

Example : <https://vimeo.com/23374724> is a valid url.

Answer: 
Try with a regex?

```
/^(http\:\/\/|https\:\/\/)?(www\.)?(vimeo\.com\/)([0-9]+)$/.test("url");

```

This should, if it start with a protocol, require it be "http://" or "https://". Then optionally have "www.". Then have "vimeo.com/". Then have a series of digits.

It's up to you what you want to require and make optional. I would think that everything but the "www." should be required, but I'm not sure of the input you're receiving/testing. To make it required, remove the `?` from the specific group (the `?` comes after the group it affects).
You can use the following regex:

```
(?:https?\:\/\/)?(?:www\.)?(?:vimeo\.com\/)([0-9]+)

```

The id of the video will be captured in group 1, if you need to use that. You can see it in action on [debuggex](http://www.debuggex.com/?re=%28?%3ahttps?%5C%3a%5C/%5C/%29?%28?%3awww%5C.%29?%28?%3avimeo%5C.com%5C/%29%28%5B0-9%5D%2b%29&flags=&str=https://vimeo.com/23374724%20and%20https://vimeo.com/23374726).