A Rust implementation of a grep-like tool, originally built as a solution for
CodeCrafters "Build your own grep" challenge.
- Zero-copy of the testing string,
- UTF-8 support,
- Wildcards,
- Positive/negative char groups,
- Start and end anchors,
- Quantifiers,
- Ranges:
a{2},a{2,4}ora{2,}, - Capture groups & backreferences.
- Word boundary:
\b, - Non-classes:
\W, \D, \B
$ echo "123 foo 456 bar 123 baz 456" | cargo run --release -- -E "(\d+).*(\d+).*\1.*\2"123 foo 456 bar 123 baz 456
$ echo "How many yaks could a yak-pack pack if a yak-pack could pack yaks?" > file.txt
$ cargo run --release -- -E "How many ((yak)s) could a (\2-(pack)) \4 if a \3 could \4 \1?" file.txtfile.txt:How many yaks could a yak-pack pack if a yak-pack could pack yaks?
$ mkdir -p dir/subdir
$ echo "🦦 🦦 🦦" > dir/subdir/file.txt
$ echo "🐼 🐼 🐼" > another_file.txt
$ cargo run --release -- -r -E "(.*) \1 \1" dir another_file.txtdir/subdir/file.txt:🦦 🦦 🦦
another_file.txt:🐼 🐼 🐼
Licensed under MIT license (LICENSE or http://opensource.org/licenses/MIT).