import re


def strip_internal_spaces(text):
    """
    Removes spaces between digits, digit and dot,
    dot and digit; after opening brackets and parentheses
    and before closing ones; spaces around ^ symbol.
    """
    text = text.replace("{ ", "{")
    text = text.replace(" }", "}")
    text = text.replace("( ", "(")
    text = text.replace(" )", ")")
    text = text.replace(" ^ ", "^")
    return re.sub(r'(?<=[\d.]) (?=[\d.])', '', text)