Regex Library in Rust - Crafting Regular Expressions with Elegance
Introduction
Dive into the world of regular expressions with the Regex Library in Rust. This project is a manifestation of my exploration into Rust programming and the creation of a regex library. The implementation is based on insights gained from the Regex Tsoding Session.
Quick Start
Ensure you have rustc
available in your $PATH
. To see the library in action, follow these steps:
$ rustc regex.rs
$ ./regex
Library Highlights
The regex library is crafted with Rust, utilizing a Finite State Machine (FSM) approach for efficient pattern matching. Here's a snippet showcasing some of the core features:
// ... (Code snippet provided in the project)
struct Regex {
cs: Vec<FsmColumn>,
}
impl Regex {
// Constructor and methods for compiling and matching regex
// ...
}
fn main() {
// Example usage and test cases
// ...
}
This Rust-based regex library supports various regex constructs, including:
- Anchors (
$
) - Wildcard (
.
) - Kleene Star (
*
) - Positive Closure (
+
) - Character matching
Explore the Code
Get hands-on with the Regex Library in Rust by exploring the source code on GitHub:
Video Session
Gain insights into the design and implementation of the regex library by watching the Regex Tsoding Session.
Test Cases
The project includes test cases covering various scenarios, ensuring the robustness of the regex library.