import string


def string_to_filename(input_string: str, replaceby: str = '_') -> str:
    """ Strip weird, confusing or special characters from input_string

    Parameters
    ----------
    input_string: str
        Input string with any character
    replaceby: str
        character to use to replace "/" and "\"

    Returns
    ----------
    out: str
        Sanitized input_string that can safely be used as filename.

    Examples
    ----------
    >>> bad_string = "i_am/a_string"
    >>> good_string = string_to_filename(bad_string)
    >>> print(good_string)
    i_am_a_string
    """
    # Allow ".", but not as the first character.
    if input_string[0] == ".":
        input_string = input_string[1:]

    # Replace "/" and "\" with `replaceby` for readability.
    striped = input_string.replace("/", replaceby).replace("\\", replaceby)

    # characters allowed
    allowed = string.digits + string.ascii_letters + "_."

    return "".join(x for x in striped if x in allowed)