hematite/agent/utils.rs
1use lazy_static::lazy_static;
2use regex::Regex;
3
4lazy_static! {
5 pub static ref ANSI_REGEX: Regex =
6 Regex::new(r"[\u001b\u009b][\[()#;?]*([0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]")
7 .unwrap();
8 pub static ref CRLF_REGEX: Regex = Regex::new(r"(?i)LF will be replaced by CRLF").unwrap();
9}
10
11pub fn strip_ansi(text: &str) -> String {
12 let s = ANSI_REGEX.replace_all(text, "").to_string();
13 CRLF_REGEX.replace_all(&s, "").to_string()
14}