[ create a new paste ] login | about

Link: http://codepad.org/b4yIVTCP    [ raw code | output | fork ]

Python, pasted on Apr 24:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import re
restring = "(Watch|Put on) (?P<videotitle>[^\s]+)(?: season )?(?P<seasonnumber>[\d]+)?(?: episode )?(?P<episodenumber>[\d]+)?"
mstring1 = "Watch abcdefg season 4 episode 2"
mstring2 = "Watch arseholes"
r1 = re.search(restring,mstring1)
r2 = re.search(restring,mstring2)

print "for: Watch abcdefg season 4 episode 2"
for n in r1.groups():
   print n

print "for: Watch arseholes"
for n in r2.groups():
   print n


Output:
1
2
3
4
5
6
7
8
9
10
for: Watch abcdefg season 4 episode 2
Watch
abcdefg
4
2
for: Watch arseholes
Watch
arseholes
None
None


Create a new paste based on this one


Comments: