import re


def format_label(label: str, full: bool = False) -> str:
    """Formats label.

    Parameters
    ----------
    label
        Original label
    full
        Full label, as 'label / unit'
    """
    if full:
        text, unit = label.rsplit('/', maxsplit=1)
    else:
        text, unit = False, label
    unit = re.sub(r'\^?([-+]?\d+)', r'$^{\1}$', unit)
    unit = re.sub(r'/(\w+)', r'\1$^{-1}$', unit)
    if text:
        res = '{} / {}'.format(text, unit)
    else:
        res = unit
    return res