import re


def __expand_ranges(expression: str) -> str:
    """Expand ranges in a given expression.

    Args:
        expression: The expression to expand.

    Returns:
        The expression with ranges expanded.
    """

    # Find {n}..{n} in the expression.
    pattern = re.compile("(\\d+)\.\.(\\d+)")

    # Expand ranges
    while True:
        match = pattern.search(expression)
        if match is None:
            break

        left, right = int(match.group(1)), int(match.group(2))
        if left <= right:
            # Replace hyphen expression with comma-separated list.
            numbers = [str(i) for i in range(left, right + 1)]
            expression = expression.replace(match.group(0), ",".join(numbers))

    return expression