Skip to content

Instantly share code, notes, and snippets.

@vortec
Created August 3, 2013 22:00
Show Gist options
  • Select an option

  • Save vortec/6148155 to your computer and use it in GitHub Desktop.

Select an option

Save vortec/6148155 to your computer and use it in GitHub Desktop.
import re
f1 = 'my movie title #12'
f2 = 'my other movie title'
my_regex = re.compile(r'^(?P<movie>.*)( #(?P<version>\d+))$')
result = re.match(my_regex, f1)
if result:
print result.groupdict()
else:
print 'couldnt match'
result = re.match(my_regex, f2)
if result:
print result.groupdict()
else:
print 'couldnt match'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment