Skip to main content

Crate resharp

Crate resharp 

Source
Expand description

resharp - regex engine with intersection, complement, and lookarounds, powered by symbolic derivatives and lazy DFA construction.

§quick start

let re = resharp::Regex::new(r"\d{3}-\d{4}").unwrap();
let matches = re.find_all(b"call 555-1234 or 555-5678").unwrap();
assert_eq!(matches.len(), 2);

§options

use EngineOptions with Regex::with_options for non-default settings:

use resharp::{Regex, EngineOptions};

let re = Regex::with_options(
    r"hello world",
    EngineOptions::default()
        .case_insensitive(true)
        .dot_matches_new_line(true),
).unwrap();
assert!(re.is_match(b"Hello World").unwrap());

§escaping user input

use escape to safely embed literal strings in patterns:

let user_input = "file (1).txt";
let pattern = format!(r"^{}$", resharp::escape(user_input));
let re = resharp::Regex::new(&pattern).unwrap();
assert!(re.is_match(b"file (1).txt").unwrap());

Structs§

EngineOptions
Engine configuration, passed to Regex::with_options.
Match
byte-offset range [start, end).
NodeId
Nullability
Regex
compiled regex backed by a lazy DFA.
RegexBuilder

Enums§

Error
error from compiling or matching a regex.
UnicodeMode
configuration for pattern compilation and engine behavior.

Functions§

escape
escape all resharp meta characters in text, returning a pattern that matches the literal string.
escape_into
like escape but appends to an existing buffer. escapes all resharp meta characters in text and appends to buf.