Last active
August 29, 2015 14:14
-
-
Save dmiro/f45d3e42f30c5c78173c to your computer and use it in GitHub Desktop.
Regular expression for youtube links
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
| import re | |
| pattern = re.compile("http://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?") | |
| print pattern.search("no link") | |
| print pattern.search("http://www.youtube.com/watch?v=ueYkNy66nuU") | |
| print pattern.search("http://www.youtube.com/movie/dentro-del-laberinto-ve") | |
| print re.search("http://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?", "http://www.youtube.com/watch?v=ueYkNy66nuU") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment