import string


def sanitise_string_for_stream_id(unsafe_string):
    """
    Removes any unhelpful characters (e.g. #,/,<space>,%) from a string.

    We pass:
        -Letters ([A-Za-z])
        -digits ([0-9]),
        -hyphens ("-"),underscores ("_"), colons (":"), and periods (".")
        -Plus symbol ('+')

    We replace '\', '/','#', and <space> by underscore.
    """
    s = unsafe_string
    if unsafe_string[0] == ".":
        s = unsafe_string[1:]
    return "".join(c for c in
                   s.replace('/', '_').replace('\\', '_'). \
                   replace('#', '_').replace(' ', '_')
                   if c in string.ascii_letters + string.digits + '_-:.+')