+ 1
ReGex problem for YT Ids catching
Hi, i was looking for a regex that would allow me to get the ids of videos and contents from YouTube, and I found this: https://regex101.com/r/OY96XI/1 However, I noticed that by entering incorrect URL addresses, they were considered as false positives. (The addresses are at the bottom of the page). I also noticed that the last address among the correct ones is not captured. Does anyone know how to correct the error of this regex? I was writing one of my own, then I found this much more effective and complex. Modified regex: https://regex101.com/r/iFiHnt/1
5 Answers
0
I've finished writing the regex, based on the forked one, if you want to do some tests on working URLs I'd be grateful, otherwise it should be able to catch most of the YT addresses correct or almost.
https://regex101.com/r/hrLz72/32
+ 4
Hi,
Test this one:
(?:https?:\/\/)?(?:www\.|m\.)?(?:youtube\.com\/(?:watch\?v=|embed\/|v\/|e\/|user\/.*#p\/u\/\d+\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})
+ 1
Thank you
0
I'm new to regex, if there was a way to remove all those groups, it would be better to read (without obviously taking away the effectiveness of the regex)
0
Some graphics card gives this option