How do I change the regexp?
-
Good evening! I found a code for my project that searches for the id of a YouTube video by regexp and inserts this excerpt in a certain place.
function parseMediaURL(media) { let regexp = /https:\/\/i\.ytimg\.com\/vi\/([a-zA-Z0-9_-]+)\/maxresdefault\.jpg/i; let url = media.src; let match = url.match(regexp); return match[1]; }
from this linkhttps://i.ytimg.com/vi/neHA4MJwpnY/maxresdefault.jpg
How to make it find id from any link, not id from the image path.
For example, from this linkhttps://youtu.be/KkcrQTqr9q4
JavaScript Natalie Stokes, Mar 31, 2019 -
Here are a couple of regulars that go over all the links I know of jsfiddle.net/1j5do56g/1Anonymous
-
the captain suggests that vi \ is not a vindette)))Anonymous
2 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!