# HG changeset patch # User Laman # Date 2024-07-15 13:50:50 # Node ID f62bf5223dbfea810ca0f8233de46c7ae325bc74 # Parent 1e7b35645ea46f5b91a3d11bfab2d76da5f9c73b added examples to the README diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Written as an exercise in Rust and a refreshment of my university classes on finite automatons. The supported syntax is restricted to the following operators: + * `*` - the Kleene star. The previous item can be present zero or more times. * Concatenation - is implied between items following each other. `ab*` matches an `a` followed by any number of `b`s * `+` or `|` - a union of several alternatives. Both symbols are equivalent. @@ -31,6 +32,19 @@ python regexp.py compare PATTERN1 PATTER ./target/release/regular-expresso compare PATTERN1 PATTERN2 ``` +### Example +``` +> ./regular-expresso match "(ab)*" abab +true +> ./regular-expresso match "(ab)*" aba +false + +> ./regular-expresso compare "ab(ab)*" "a(ba)*b" +None +> ./regular-expresso compare "a*" "(_|a|aa)" +aaa +``` + ## Theory 1. The pattern gets parsed into a tree of its parts. 2. We check which symbols can stand at the beginning, which can follow each other and which can stand at the end of the string. These data are used to construct a non-deterministic finite automaton (NFA).