python regex
Wednesday, March 25th, 2009I don't know why, but I never knew about the grouping that was possible in Python's re module. I've been using Python this long and suddenly realize it's there... a true facepalm moment. Anyway, how's this for cool? -
PYTHON:
-
import re
-
string = "S03E12 - A random filename"
-
print re.match(r'.*S(?P<season>\d+).*E(?P<episode>\d+)', string).groupdict()
technobabbler