Global flag
I tried, just for curiosity, against this URL https://www.youtube.com/watch?v=_T2Dxgn-lls in a normal Firefox browser with normal .match and it wouldn't work unless removing the g flag. After removing it the regex returned the id in the array as needed. Is this the wanted behaviour?
Hi, it's just a function that returns a regex, nothing more, so..
But yea, you have right and it may be good to have options as the other packages in that org have. i'll try to do that tonight.
it wouldn't work
what you mean with that?
I just meant it doesn't work without removing the flag, sorry. Again, this was just my usecase, it might not apply well in other contexts.
Mainly, my question - in other words - was why is there a "nested" capture for the ID if just the first match is returned.
Can you try it on chrome? Or what version of FF you use? I'm noticing now few "firefox specific notes" in mozilla docs https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/match
I've tried with the latest version of Firefox under Windows 10 64 bits, I can tell you more tomorrow; I didn't know Firefox was "special".�
I didn't know Firefox was "special".
Haha, same here. In anyway, i'm not using it from v3, lol.. Yea.. that's was years ago, and it was good.. mm yea.
So, I run some tests, here the results.
With global flag:
"https://www.youtube.com/watch?v=_T2Dxgn-lls".match(/(?:youtube\.com\/\S*(?:(?:\/e(?:mbed))?\/|watch\/?\?(?:\S*?&?v\=))|youtu\.be\/)([a-zA-Z0-9_-]{6,11})/g)
- Firefox 46.0.1, Windows 10 64 bit; Firefox 46.0, Ubuntu 16.04 64-bit
Array [ "youtube.com/watch?v=_T2Dxgn-lls" ] - Microsoft Edge
[object Array]["youtube.com/watch?v=_T2Dxgn-lls"] - Chromium 49.0.2623.108, Ubuntu 16.04 64-bit
["youtube.com/watch?v=_T2Dxgn-lls"] - Node.js v6.1.0, Ubuntu 16.04 64-bit
[ 'youtube.com/watch?v=_T2Dxgn-lls' ]
Without global flag:
"https://www.youtube.com/watch?v=_T2Dxgn-lls".match(/(?:youtube\.com\/\S*(?:(?:\/e(?:mbed))?\/|watch\/?\?(?:\S*?&?v\=))|youtu\.be\/)([a-zA-Z0-9_-]{6,11})/)
- Firefox 46.0.1, Windows 10 64 bit; Firefox 46.0, Ubuntu 16.04 64-bit
Array [ "youtube.com/watch?v=_T2Dxgn-lls", "_T2Dxgn-lls" ] - Microsoft Edge
[object Array]["youtube.com/watch?v=_T2Dxgn-lls", "_T2Dxgn-lls"] - Chromium 49.0.2623.108, Ubuntu 16.04 64-bit
["youtube.com/watch?v=_T2Dxgn-lls", "_T2Dxgn-lls"] - Node.js v6.1.0, Ubuntu 16.04 64-bit
[ 'youtube.com/watch?v=_T2Dxgn-lls', '_T2Dxgn-lls' ]
Do really Chrome and Chromium behave differently?
Hm, interesting, so probably we should rethink it. PRs welcome, since it works in node.