On 2010-11-30, goldtech <goldt...@worldpost.com> wrote: > Hi, > > say: >>>> import re >>>>> m="oooocccvlvlvlvnnnflfllffccclfnnnooo" >>>> re.compile(r'ccc.*nnn') >>>> rtt=pppp.sub("||",m) >>>> rtt > 'oooo||ooo' > > The regex is eating up too much. What I want is every non-overlapping > occurrence I think. > > so rtt would be: > > 'oooo||flfllff||ooo'
Python 3.1.2 (r312:79147, Oct 9 2010, 00:16:06) [GCC 4.4.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> m="oooocccvlvlvlvnnnflfllffccclfnnnooo" >>> pattern = re.compile(r'ccc[^n]*nnn') >>> pattern.sub("||", m) 'oooo||flfllff||ooo' >>> -- http://mail.python.org/mailman/listinfo/python-list