import re


def sub_power(text_in: str) -> str:
    """ substitution of powers

    Replaces:
    cm-3 with cm**-3.

    Parameters
    ----------
    text_in: str

    Returns
    -------
    text: str

    """
    found_unit_power = re.findall("[a-zA-Z]{1,10}[-+]?[0-4]", text_in)
    for exp in found_unit_power:
        if "-" in exp:
            exp_new = exp.replace("-", "**-", 1)
        elif "+" in exp:
            exp_new = exp.replace("+", "**", 1)
        else:
            exp_new = exp[:-1] + "**" + exp[-1]
        text_in = text_in.replace(exp, exp_new)

    return text_in.strip()