Regex for matching this string
Question: With python ( regex module ), I am triying to substitute 'x' for each letter
'c' in those strings occurring in a text and:

  1. delimited by 'a', at the left, and 'b' at the right, and

  2. with no more 'a's and 'b's in them.

Example:

`cuacducucibcl` -> `cuaxduxuxibcl`

How can I do this?

Thank you.


Answer: With the standard `re` module in Python, you can use `a[^ab]+b` to match the
string which starts and end with `a` and `b` and doesn't have any occurence of
`a` or `b` in between, **then** supply a replacement function to take care of
the replacement of `c`:

    
    
    >>> import re
    >>> re.sub('a[^ab]+b', lambda m: m.group(0).replace('c', 'x'), 'cuacducucibcl')
    'cuaxduxuxibcl'
    

Document of [`re.sub`](https://docs.python.org/2/library/re.html#re.sub) for
reference.

