Re: Nothing to repeat

2011-01-09 Thread Terry Reedy
On 1/9/2011 11:49 AM, Tom Anderson wrote: Hello everyone, long time no see, This is probably not a Python problem, but rather a regular expressions problem. I want, for the sake of arguments, to match strings comprising any number of occurrences of 'spa', each interspersed by any number of occu

Re: Nothing to repeat

2011-01-09 Thread Martin Gregorie
On Sun, 09 Jan 2011 16:49:35 +, Tom Anderson wrote: > > Any thoughts on what i should do? Do i have to bite the bullet and apply > some cleverness in my pattern generation to avoid situations like this? > This sort of works: import re f = open("test.txt") p = re.compile("(spam*)*") for line

Re: Nothing to repeat

2011-01-09 Thread Ian
On 09/01/2011 17:49, Ian wrote: I think you want to anchor your list, or anything will match. Perhaps My bad - this is better re.compile('^((spa)*(m)*)+$') search finds match in 'spa', 'spaspaspa', 'spammmspa', '' and 'mmm' search fails on 'spats', 'mats' and others. -- http://mail.p

Re: Nothing to repeat

2011-01-09 Thread Ian
On 09/01/2011 16:49, Tom Anderson wrote: Hello everyone, long time no see, This is probably not a Python problem, but rather a regular expressions problem. I want, for the sake of arguments, to match strings comprising any number of occurrences of 'spa', each interspersed by any number of o