RegEx to Extract Video ID from YouTube URLs

The regular expression will extract the video ID from any YouTube URL and it works with shortened URLs (youtu.be) and embed URLs (youtube.com/embed/) as well.

Another alternative that will extract the video ID as well as the playlist ID from YouTube URLS: