YouTube Video ID Grabber - Works for both video and shorts
This page is designed to extract the video ID from a YouTube video URL. I have used a simple JavaScript regular expression to match the pattern and extract the video ID from the string. The JavaScript regular expression code is provided below,
/[?=/]([A-Za-z0-9_-]{10}[AEIMQUYcgkosw048])[?=/]*?/g
Live demonstration:
YouTube Video ID Grabber
|
Regular Expression Explanation
[
Character set. Match any character in the set.
?
Character. Matches a "?" character (char code 63).=
Character. Matches a "=" character (char code 61)./
Character. Matches a "/" character (char code 47).]
(
Capturing group #1. Groups multiple tokens together and creates a capture group for extracting a substring or using a backreference.
[
Character set. Match any character in the set.A-Z
Range. Matches a character in the range "A" to "Z" (char code 65 to 90). Case sensitive.a-z
Range. Matches a character in the range "a" to "z" (char code 97 to 122). Case sensitive.0-9
Range. Matches a character in the range "0" to "9" (char code 48 to 57). Case sensitive._
Character. Matches a "_" character (char code 95).-
Character. Matches a "-" character (char code 45).]
{10}
Quantifier. Match 10 of the preceding token.[
Character set. Match any character in the set.A
Character. Matches a "A" character (char code 65). Case sensitive.E
Character. Matches a "E" character (char code 69). Case sensitive.I
Character. Matches a "I" character (char code 73). Case sensitive.M
Character. Matches a "M" character (char code 77). Case sensitive.Q
Character. Matches a "Q" character (char code 81). Case sensitive.U
Character. Matches a "U" character (char code 85). Case sensitive.Y
Character. Matches a "Y" character (char code 89). Case sensitive.c
Character. Matches a "c" character (char code 99). Case sensitive.g
Character. Matches a "g" character (char code 103). Case sensitive.k
Character. Matches a "k" character (char code 107). Case sensitive.o
Character. Matches a "o" character (char code 111). Case sensitive.s
Character. Matches a "s" character (char code 115). Case sensitive.w
Character. Matches a "w" character (char code 119). Case sensitive.0
Character. Matches a "0" character (char code 48).4
Character. Matches a "4" character (char code 52).8
Character. Matches a "8" character (char code 56).]
)
[
Character set. Match any character in the set.
?
Character. Matches a "?" character (char code 63).=
Character. Matches a "=" character (char code 61)./
Character. Matches a "/" character (char code 47).]
*
Quantifier. Match 0 or more of the preceding token.?
Lazy. Makes the preceding quantifier lazy, causing it to match as few characters as possible.YouTube Video ID Explanation
YouTube videos consist of a 64-bit ID. The final character of a video ID can only have one of 16 values since an 11-character base64 string is equivalent to 66 bits.
Video ID regular expression pattern: [A-Za-z0-9_-]{10}[AEIMQUYcgkosw048]
This article illustrates how to obtain the YouTube video ID alone. Google maintains many formats for YouTube playlists and channels. Furthermore, videos and shorts on YouTube include distinct URLs. For more details, refer https://wiki.archiveteam.org/index.php/YouTube/Technical_details.
Comments
Post a Comment