def clean(s):
    """
    Adds escape characters for a string.
    """
    s = s.replace(r'{', r'\{')
    s = s.replace(r'}', r'\}')
    s = s.replace(r'_', r'\_')
    s = s.replace(r'%', r'\%')
    return s