Closed Araxeus closed 3 years ago
Nice @Araxeus!
Thank you :+1:
@alxhotel by the way, whats the point of the other capture group? (&(amp;)?[\w\?=]*)?
It seems only the first group is used anyways. maybe its a leftover from somewhere?
Could maybe remove it, shortened version would be:
/http(?:s?):\/\/(?:www\.)?(?:music\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)/`
Also i think http/s
should maybe be optional with (?:http(?:s?):\/\/)?
. final result:
/(?:http(?:s?):\/\/)?(?:www\.)?(?:music\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)/
The (&(amp;)?[\w\?=]*)?
group is so that the regex can match the whole string and not just a part of it. But I guess that we can get rid of it if we allow a partial match.
Yep, we can also make the http
prefix optional if you want :)
added the option to use music.youtube links (which have the same id as normal youtube) by adding
(?:music\.)?
to the regex full new regex:Example:
this capture id
JYC8aINHFxc
from https://music.youtube.com/watch?v=JYC8aINHFxc&list=PLtkJ7CALZYL9rGWDQ7V_PX60Kth5Nq3Ry which is the same as https://www.youtube.com/watch?v=JYC8aINHFxc