def string_replacer(line):
    """Take string literals like 'hello' and replace them with empty string literals, while respecting escaping."""

    r = []
    in_quote = None
    escapes = 0
    for i, c in enumerate(line):
        if in_quote:
            if not escapes and c == in_quote:
                in_quote = None
                r.append(c)
                continue

            # We're inside of a string literal. Ignore everything.
        else:
            if not escapes and (c == '"' or c == "'"):
                in_quote = c
                r.append(c)
                continue

            # Outside of a string literal, preserve everything.
            r.append(c)

        if c == '\\':
            escapes = (escapes + 1) % 2
        else:
            escapes = 0

    if in_quote:
        # Unterminated string literal.
        pass
    return "".join(r)