On May 9, 3:19 pm, globalrev <[EMAIL PROTECTED]> wrote: > i want to a little stringmanipulationa nd im looking into regexps. i > couldnt find out how to do: > s = 'poprorinoncoce' > re.sub('$o$', '$', s) > should result in 'prince' > > $ is obv the wrng character to use bu what i mean the pattern is > "consonant o consonant" and should be replace by just "consonant". > both consonants should be the same too. > so mole would be mole > mom would be m etc
>>> import re >>> s = s = 'poprorinoncoce' >>> coc = re.compile(r"(.)o\1") >>> coc.sub(r'\1', s) 'prince' Matt -- http://mail.python.org/mailman/listinfo/python-list