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'
>>> # or, assuming that the middle sequence might contain singular or
>>> # double 'n's
>>> pattern = re.compile(r'ccc.*?nnn')
>>> pattern.sub("||", m)
'oooo||flfllff||ooo'
>>>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to