difficult regular expression

Mike Rovner mike at bindkey.com
Wed Oct 30 01:26:08 CET 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