difficult regular expression

Mike Rovner mike at bindkey.com
Tue Oct 29 19:26:08 EST 2002


> >>> {'Cats': ['ice', 'rats', 'rabbits', 'marmots'], 'Chickens': ['rain',
> 'corn', 'wheat'], 'Dogs': ['hicken', 'rice', 'steak']}

Oops!

Drop space between eat and (:
pattern = re.compile( r'(\w+) eat(.*), and other foods\.' )

{'Cats': ['mice', 'rats', 'rabbits', 'marmots'], 'Chickens': ['grain',
'corn', 'wheat'], 'Dogs': ['chicken', 'rice', 'steak']}

m.








More information about the Python-list mailing list