I created the YT Regexp to match the ID of the video and it works in the Regex service - regex101 but in the real code it doesn't detect the ID somehow. On the attached screenshot you can see that in the service there is existing an ID group in the match result however in the console isn't.
I'm wondering how it's possible? Maybe my regexp is incorrect or is it some Regex specific behavior?
I'll appreciate any help/info!
Here is the code: My regexp
const YT_ID_REGEXP = /(?:https?:\/\/(?:www)?\.?y(?:2u\.be|outu\.be|outube.com)\/)(?:watch\?v=)?([\w\d]+)/gim;
It recognizes the standard YT link such as:
http://www.youtube.com/watch?v=Kmiw4FYTg2U
and the shortcuts like:
http://youtu.be/ZRX8984sc
or
http://y2u.be/w7ejDZ8SWv8
I prepared the playground & demo regex101 service demo
Hello, world!
'; let tag = str.match(/<(.*?)>/); console.log(tag)` – Velidan Aug 05 '21 at 08:04