https://github.com/luckasranarison/regex-potata
Potata regex engine
https://github.com/luckasranarison/regex-potata
automata-theory nfa regex-engine thompson-construction
Last synced: 6 months ago
JSON representation
Potata regex engine
- Host: GitHub
- URL: https://github.com/luckasranarison/regex-potata
- Owner: luckasRanarison
- License: mit
- Created: 2023-12-19T09:17:56.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-31T06:55:24.000Z (over 1 year ago)
- Last Synced: 2025-04-02T04:04:56.173Z (6 months ago)
- Topics: automata-theory, nfa, regex-engine, thompson-construction
- Language: Rust
- Homepage: https://luckasranarison.github.io/regex-potata/
- Size: 267 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Regex-potata
A basic regex engine, built as a practical application of automata theory, implements an E-NFA using Thompson construction and BFS for NFA simulation.
## Usage
```rust
use regex_potata::Regex;fn main() {
let re = Regex::new("hello (w|w)orld!*").unwrap();
let result = re.test("hello world!!!");println!("{}", result); // true
let re = Regex::new(r#"(?\d{2})-(?\d{2})-(?\d{4})"#).unwrap();
let captures = re.captures("07-01-2024").unwrap();println!("{:?}", captures.get_name("day"));
println!("{:?}", captures.get_name("month"));
println!("{:?}", captures.get_name("year"));let re = Regex::new("(T|t)h(e|(e|o)se)").unwrap();
let matches = re.find_all("the These those The");println!("{:?}", matches);
}
```## TODOs
- [x] Basic regex `foo` `(bar)` `|` `.`
- [x] Quantifiers `+` `?` `*` `{x}` `{x,y}` `{x,}`
- [x] Character classes `[a-z]` `[^x]` `\d` `\D` `\w` `\W` `\s` `\S`
- [x] Captures `(foo)` `(:?bar)` `(?foo)`
- [ ] Anchors `^` `$`
- [ ] NFA visualizer