Linux Panda

Open Source | Linux | Android | Tech

Tag Archives: playlist

Regex to get youtube video/playlist id with time & generate embed code

To embed youtube videos in a website, the best solution is to parse a string to match for youtube url and then grab the youtube VIDEO_ID or PLAYLIST_ID from the url and then use that video id in a standard embed code.

This is one of the ultimately best regex (regular expression) pattern to get/grab/parse youtube video id from any youtube link/url.

This regex works

  1. with or without http/https
  2. with or without www
  3. with both youtube.com & youtu.be links

This regex can be used to grab

  1. youtube video id
  2. youtube playlist id

 

Read more of this post