| Crates.io | regex_ansi |
| lib.rs | regex_ansi |
| version | 0.1.0 |
| created_at | 2025-09-09 15:24:46.201261+00 |
| updated_at | 2025-09-09 15:24:46.201261+00 |
| description | ANSI escape sequence regular expression (Rust port of ansi-regex behavior) |
| homepage | |
| repository | https://github.com/MuntasirSZN/regex_ansi |
| max_upload_size | |
| id | 1831064 |
| size | 37,347 |
High‑fidelity Rust port of the popular JavaScript ansi-regex pattern. Supplies a battle‑tested regular expression that matches ANSI escape sequences (CSI, OSC, etc.).
use regex_ansi::ansi_regex;
fn main() {
let text = "\x1b[31mError:\x1b[0m something failed";
let cleaned = ansi_regex().replace_all(text, "");
assert_eq!(cleaned, "Error: something failed");
}
ansi-regex@6 (JS).ansi_regex) and first match style (ansi_regex_first).pub fn ansi_regex() -> &'static regex::Regexpub fn ansi_regex_first() -> &'static regex::Regexpub fn pattern() -> &'static str – raw pattern string.Licensed under MIT. Derivative work conceptually based on the pattern logic from the original JavaScript project.