summaryrefslogtreecommitdiff
path: root/cmd2/utils.py
blob: 33215dc02ea20ead0188e28e19b6d659466d67b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#
# coding=utf-8
"""Shared utility functions"""

from . import constants

def strip_ansi(text: str) -> str:
    """Strip ANSI escape codes from a string.

    :param text: string which may contain ANSI escape codes
    :return: the same string with any ANSI escape codes removed
    """
    return constants.ANSI_ESCAPE_RE.sub('', text)