def METHOD_NAME(filename: str) -> str:
    """Replace all non-alphanumeric symbols by underscores.
    >>> from . import regression
    >>> for x in [ "Gaussian/Gaussian03/Mo4OSibdt2-opt.log" ]:
    ...     print(regression.normalisefilename(x))
    ...
    Gaussian_Gaussian03_Mo4OSibdt2_opt_log
    """
    # TODO This is duplicated from test/regression.py, where it can be removed
    # after all (dynamically generated) regression tests are converted to run
    # via pytest.
    ans = []
    for y in filename:
        x = y.lower()
        if (x >= 'a' and x <= 'z') or (x >= '0' and x <= '9'):
            ans.append(y)
        else:
            ans.append("_")
    return "".join(ans)