I have the following code:
import re
pattern = re.compile('^(.+)\'s (.+)$',re.I)
string = "bill's uncle's pony"
matchObjects = pattern.finditer(string)
for i in matchObjects:
if i:
print i.group(1)
print i.group(2)
This produces the output:
bill's uncle
pony
When I hoped it would produce the output
bill's uncle
pony
bill
uncle's pony
That is, I want all the ways in which the string matches. This code only gives me one of them. Any ideas much appreciated.