Created
September 26, 2014 15:52
-
-
Save matiasherranz/3230dce4483b1119aca6 to your computer and use it in GitHub Desktop.
Get filename extension function, using a regex.
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 | |
def get_extension(filename): | |
regex = re.compile(r'^.*?[.](?P<ext>tar\.gz|tar\.bz2|\w+)$') | |
return regex.match(filename).group('ext') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment