Is this even possible?
Basically, I want to turn these two calls to sub into a single call:
re.sub(r\'\\bAword\\b\', \'Bword\', mystring) re.sub(r\'\
You can have functions to parse every match:
>>> def f(match): return chr(ord(match.group(0)[0]) + 1) + match.group(0)[1:] >>> re.sub(r'\b[aA]word\b', f, 'aword Aword') 'bword Bword'