Created
August 15, 2019 21:23
-
-
Save JonasAlfredsson/dcf99ae8f70e385c70d404521d7c4655 to your computer and use it in GitHub Desktop.
YouTube URL regex for bash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [[ $URL =~ ^(https?://)?(www.)?(youtu.be/|youtube.com/(embed/|v/|watch\?v=|watch\?.+&v=|playlist\?list=))([[:alnum:]|_|-]{11})($|&(.+)?) ]]; then | |
# This seems to be a link from YouTube with some video ID attached. | |
else | |
# This was not recognized as a YouTube link. | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment