import re


def crush_invalid_field_name(name):
    """Given a proposed field name, replace banned characters with underscores, and convert any run of underscores with a single."""
    if name[0].isdigit():
        name = "_%s" % name
    name = re.sub(r'[^a-z0-9_]', "_", name.lower())
    return re.sub(r'__*', "_", name, flags=re.I)