Expand description
regex engine with intersection, complement, and lookarounds
§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 RegexOptions with Regex::with_options for non-default settings:
use resharp::{Regex, RegexOptions};
let re = Regex::with_options(
r"hello world",
RegexOptions::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§
- Match
- byte-offset range
[start, end). - Regex
- Lazily compiled regex instance. Uses Mutex for interior mutability.
- Regex
Options - Regex configuration, passed to
Regex::with_options. - Stream
State - Opaque DFA state for
Regex::stream_chunk.
Enums§
- Error
- error from compiling or matching a regex.
- Unicode
Mode - 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
escapebut appends to an existing buffer. escapes all resharp meta characters intextand appends tobuf.