import re


def note_filename_from_query(fn: str) -> str:
    """
    Remove characters from note title that could cause filename problems
    """
    fn = re.sub(r"[^a-zA-Z0-9 _\-\/]", "", fn)
    fn = re.sub(r"\s+", " ", fn)
    fn = re.sub(r"^\s+", "", fn)
    fn = re.sub(r"\s+$", "", fn)
    return fn