stripAnsi

Provides an InputRange that iterates over all non-ANSI related parts of input.

This can effectively be used to parse over text that is/might contain ANSI encoded text.

@safe @nogc nothrow pure
stripAnsi
(
const char[] input
)

Parameters

input char[]

The input to strip.

Return Value

Type: auto

An InputRange that provides all ranges of characters from input that do not belong to an ANSI command sequence.

Examples

import std.array : array;

auto ansiText = "ABC".ansi.fg(Ansi4BitColour.red).toString()
              ~ "Doe Ray Me".ansi.bg(Ansi4BitColour.green).toString()
              ~ "123";

assert(ansiText.stripAnsi.array == ["ABC", "Doe Ray Me", "123"]);

See Also

asAnsiSections

Meta