import re


def collapse_spaces(text: str) -> str:
    """Substitutes two or more spaces with only one.

    Parameters:
    text: str - string where to do the replacement

    Returns:
    clean_text: str - string with two o more spaces substitued by only one
    """
    pattern = re.compile(r"\s+")
    clean_text = pattern.sub(r" ", text)
    return clean_text