What's the problem with regex?

  • 0
    There is this expression

    search for YouTube id follows the link of the picture. I make the expression look for the standard link https://youtu.be/KkcrQTqr9q4
    like this -
    let regexp = /https:\/\/youtu\.be\/\([a-zA-Z0-9_-]+)/;
    but it doesn't work. Where is the mistake
    JavaScript Anonymous, Apr 24, 2020

  • 2 Answers
  • 0
    In the code, you get the video__media element, assign it to the media variable, and then write let url = media.src; . Apparently, this is an ifram, and here is an error, you need to get the value in src like this: let url = media.getAttribute ('src'); should work

  • 0
    You have escaped the opening parenthesis and it has changed from a service symbol for the beginning of a group into a regular expression symbol.

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