I found the following regex substitution example from the manual for Regex. I'm a little bit unclear as to what the prefix r does before the string?
re.sub(r'def\s+
([a-zA-Z ][a-zA-Z 0-9]*)\s*\(\s*\):',
... r'static PyObject*\npy_\1(void)\n{',
... 'def myfunc():')