| Crates.io | rusty_regex |
| lib.rs | rusty_regex |
| version | 0.2.4 |
| created_at | 2025-04-04 04:29:52.672331+00 |
| updated_at | 2025-07-11 16:20:55.985164+00 |
| description | A minimalistic regex engine using the pipeline: Regex -> AST -> NFA -> DFA -> Match(String) |
| homepage | https://example.com/rusty_regex |
| repository | https://example.com/rusty_regex |
| max_upload_size | |
| id | 1619397 |
| size | 70,969 |
Rusty Regex is a regex engine written without dependencies. It compiles a regex pattern into an Abstract Syntax Tree (AST), then builds a Non-deterministic Finite Automaton (NFA), converts that NFA into a Deterministic Finite Automaton (DFA) via subset construction, and finally uses the DFA to match input strings.
"abc"). matching any single character[abc][a-c]\d for digits\w for word characters (letters, digits, underscore)*)+)?){n}){m,n} or {m,})|) for alternatives^) and end ($) anchors to match input positionsRusty Regex works in several phases:
Below is a simple example demonstrating how to compile a regex and test input strings:
use rusty_regex::Regex;
fn main() {
// Compile a regex pattern.
let regex = Regex::new("^(a|b)*c$").unwrap();
// Test various inputs.
let tests = vec![
("aaabc", true),
("bbc", true),
("c", true),
("aaab", false),
];
for (input, expected) in tests {
let result = regex.is_match(input);
println!("Input: {:?}, Match: {}, Expected: {}", input, result, expected);
}
}