strip
Removes the ANSI escape sequences from text, leaving what a terminal would display.
Handles the colors and styles (ESC [ ... m) and every other CSI sequence (cursor moves, erase),
operating system commands such as window titles and hyperlinks (ESC ] ... BEL or
ESC ] ... ESC \), and the two-character escapes (ESC c, ESC 7, ESC ( B). A lone
escape character is dropped, and a sequence cut short at the end of the text is dropped with
it. Returns the input borrowed, without allocating, when it has no escape character.
Import
Section titled “Import”Cargo feature ansi (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
text | &str | The text that may contain escape sequences, such as captured command output. |
Returns
Section titled “Returns”Cow<'_, str> — The text without escape sequences.
