This is a C++ implementation of the "Build Your Own grep" Challenge.
This grep implementation supports the following regular expression features:
- Literal characters:
a,b,1,2, etc. - Digits:
\\d - Word characters:
\\w - Positive Character Groups:
[abc] - Negative Character Groups:
[^abc] - Start of string anchor:
^ - End of string anchor:
$ - One or more times:
+ - Zero or one times:
? - Wildcard:
. - Alternation:
| - Backreferences:
\\1,\\2, etc.
- Ensure you have
cmakeinstalled locally. - Run
cmake .to generate build files. - Run
maketo compile the project. - The executable will be named
exe.
To search from standard input, provide the -E flag and a pattern:
echo "hello world" | ./exe -E "world"To search a single file, provide the file path after the pattern:
./exe -E "pattern" file.txtTo search multiple files, provide the file paths after the pattern:
./exe -E "pattern" file1.txt file2.txtTo perform a recursive search in a directory, provide the directory path:
./exe -E "pattern" my_directory/The main entry point is in src/Server.cpp. The pattern matching logic is implemented in src/pattern_matcher.cpp and src/pattern_matcher.h.