import re


def clean_text(text, *, replace='_'):
    """
    Ensure input contains ONLY ASCII characters valid in filenames.
    Any other character will be replaced with 'replace'.
    Characters added in extras will be whitelisted in addiction to normal ASCII.

    Args:
        text: The text to clean.
        replace: The replacement character to use.
        extras: Additional characters to whitelist.

    Returns:
        The cleaned text.
    """
    text = re.sub(r'[^a-zA-Z0-9]', replace, text)
    text = re.sub(r'{r}{r}+'.format(r=replace), replace, text)

    return text