+ 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

19th Nov 2024, 10:15 PM
Mick
Mick - avatar
2 Réponses
+ 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})
20th Nov 2024, 11:10 AM
Per Bratthammar
Per Bratthammar - avatar
+ 1
Thank you
20th Nov 2024, 5:26 PM
Mick
Mick - avatar