import re


def valid_filename(text):
    """Turn a string into a valid filename.

    :param string text: The string to convert.
    :returns string: A valid filename derived from the string.
    """
    text = text.strip().replace(' ', '_')
    return re.sub(r'(?u)[^-\w.]', '', text)