python regex

I 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? –

[code]
import re
string = “S03E12 – A random filename”
print re.match(r’.*S(?P\d+).*E(?P\d+)’, string).groupdict()
[/code]

Leave a Reply