regex_ansi
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.).
Example
use ansi_regex;
Features
- Constant, pre‑audited pattern identical in semantics to
ansi-regex@6(JS). - Two ready regex constructors: global style (
ansi_regex) and first match style (ansi_regex_first). - No unsafe code.
API
pub fn ansi_regex() -> &'static regex::Regexpub fn ansi_regex_first() -> &'static regex::Regexpub fn pattern() -> &'static str– raw pattern string.
Performance Notes
- The OSC portion is implemented using a negated character class for linear behavior.
License
Licensed under MIT. Derivative work conceptually based on the pattern logic from the original JavaScript project.