Skip to content

Instantly share code, notes, and snippets.

@dpenfoldbrown
Created August 20, 2013 15:45
Show Gist options
  • Save dpenfoldbrown/6283228 to your computer and use it in GitHub Desktop.
Save dpenfoldbrown/6283228 to your computer and use it in GitHub Desktop.
# Simple re examples in python
import re
files = ("re_pro_p00012.txt", "re_neg_p00014.txt", "lrr_p00014.txt")
category_pattern = r"(?P<category>[a-zA-Z]+)_.*"
for file in files:
match = re.match(category_pattern, file)
print match.group("category")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment