Advertisement
Mangus875

Youtube link regex

Jun 3rd, 2023 (edited)
1,461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.44 KB | None | 0 0
  1. /^(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:watch\?.*v=|embed\/|v\/|u\/\w\/|playlist\?.*list=)|youtu\.be\/)([\w-]{11})(?:[\?&].*|)$/g
  2.  
  3. This regular expression can recognize YouTube links in formats such as:
  4. https://www.youtube.com/watch?v=VIDEO_ID
  5. https://www.youtube.com/embed/VIDEO_ID
  6. https://www.youtube.com/v/VIDEO_ID
  7. https://www.youtube.com/u/USERNAME/VIDEO_ID
  8. https://www.youtube.com/playlist?list=PLAYLIST_ID
  9. https://youtu.be/VIDEO_ID
Tags: youtube regex
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement