Re: [Tutor] Generating all possible hits of a regex pattern

2007-01-31 Thread Kent Johnson
Barton David wrote: > I don't suppose there's a nifty trick (exploiting the internal workings > of the re module perhaps) to generate all possible hits of a given regex > pattern? > > Something like: > >> >> import re >> >> mypattern=re.compile( "[AB]C{1,2}D?" ) >> >> print list( all_pattern_

[Tutor] Generating all possible hits of a regex pattern

2007-01-31 Thread Barton David
I don't suppose there's a nifty trick (exploiting the internal workings of the re module perhaps) to generate all possible hits of a given regex pattern? Something like: >>> import re >>> mypattern=re.compile( "[AB]C{1,2}D?" ) >>> print list( all_pattern_generator( mypattern ) ) ["AC","BC","ACC