How do I change the regexp?

  • 0
    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 link

    How to make it find id from any link, not id from the image path.
    For example, from this link
    JavaScript Natalie Stokes, Mar 31, 2019

  • 2 Answers
  • 0
    Here are a couple of regulars that go over all the links I know of

  • 0
    the captain suggests that vi \ is not a vindette)))

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!