re.sub replacement text \-escapes woe

Alexander Schmolck a.schmolck at gmx.net
Fri Feb 13 18:35:36 EST 2004


Sorry if I missed something obvious, but how do you do this more
intelligently?

def escape(s):
    return re.sub(r'([${}\\])', r'\ \1', s).replace('\\ ', '\\')

'as



More information about the Python-list mailing list