Created
September 26, 2014 15:54
-
-
Save matiasherranz/284b48cf3c00650d1159 to your computer and use it in GitHub Desktop.
Get filename extension function, using a regex. Keep the point.
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