1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! ANSI stripping utilities
//!
//! Provides utilities for removing ANSI escape sequences from text.
extern crate alloc;
use String;
use ;
/// Remove all ANSI escape sequences from text.
///
/// Returns the visible text content with all ANSI codes stripped.
///
/// # Arguments
///
/// * `text` - Input text potentially containing ANSI escape sequences
///
/// # Returns
///
/// String with all ANSI escape sequences removed.
///
/// # Examples
///
/// ```rust
/// # #[ cfg( feature = "ansi" ) ]
/// # {
/// use strs_tools::ansi::strip;
///
/// assert_eq!( strip( "\x1b[31mred\x1b[0m" ), "red" );
/// assert_eq!( strip( "\x1b[1;31mbold red\x1b[0m normal" ), "bold red normal" );
/// assert_eq!( strip( "plain text" ), "plain text" );
/// # }
/// ```
///
/// # Performance
///
/// - Time complexity: O(n)
/// - Space complexity: O(n) for output string
/// - Benchmark: ~500ns/KB on modern hardware