Last active
August 29, 2015 14:08
-
-
Save rvill/d759d75a476c0a205573 to your computer and use it in GitHub Desktop.
Grab image id from flickr URL with regular expression in python
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
url = 'https://farm4.staticflickr.com/3943/15386021170_c2607cb639_z.jpg' | |
#\d+ match digits; \D+ match a non-digit which is "/" after the 1st 4 digits; (d\+) get the last set of digits, in group(6) | |
re.search(r'^(https://)?(farm4\.)?(staticflickr\.com/)?(\d+)?(\D+)(\d+)',url).group(6) | |
#returns 15386021170 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment