Skip to content

Ruberald/regex-engine-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust NFA Regex Engine

A simple regex engine implemented in Rust using NFA (Non-deterministic Finite Automata) construction.

Features

  • Parses a subset of regex patterns into an NFA.
  • Supports:
    • Literal matching
    • Concatenation
    • Alternation (|)
    • Kleene star (*)
    • Plus repetition (+)
    • Optional (?) [if implemented in builder]
  • Runs a basic match computation on input strings.

Note: Advanced regex features like lookarounds, character classes, and named captures are not yet implemented.


Example Regex Patterns That Work

Here are some patterns you can test without hitting unimplemented features:

Pattern Meaning
ab*c 'a' followed by zero or more 'b''s, then 'c'
`dog cat`
a.*z 'a' followed by anything, ending with 'z'
xyz+ 'x' 'y' and one or more 'z''s
`(a b)c*`

Running the Engine

1. Clone & Build

git clone https://github.com/yourusername/regex-nfa-engine.git
cd regex-nfa-engine
cargo build

Example Run

=== NFA Regex Engine ===
Choose an option:
0) Enter your own regex
1) ab*c    [an 'a' followed by zero or more 'b's, then 'c']
2) a*c|b+    [a's then c OR one or more b's]
3) hello|world    [matches 'hello' or 'world']
Enter choice: 1
Using regex: ab*c
Enter string to test (or 'quit' to exit): abc
For 'abc': true

About

A simple Regex Engine in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages