import re


def create_valid_filename(name):
    """Return a valid filename from a string. See
    https://stackoverflow.com/questions/295135/turn-a-string-into-a-valid-filename
    for what 'valid' means in this context


    Args:
        name (str): A name (usually a page or image title)

    Returns:
        str: A valid string

    """

    name = str(name).strip().replace(' ', '_').lower()
    return re.sub(r'(?u)[^-\w.]', '', name)