Skip to content

prashu0705/grep-cpp

Repository files navigation

progress-banner

This is a C++ implementation of the "Build Your Own grep" Challenge.

Features

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.

Usage

Building the project

  1. Ensure you have cmake installed locally.
  2. Run cmake . to generate build files.
  3. Run make to compile the project.
  4. The executable will be named exe.

Searching from stdin

To search from standard input, provide the -E flag and a pattern:

echo "hello world" | ./exe -E "world"

Searching a single file

To search a single file, provide the file path after the pattern:

./exe -E "pattern" file.txt

Searching multiple files

To search multiple files, provide the file paths after the pattern:

./exe -E "pattern" file1.txt file2.txt

Recursive search

To perform a recursive search in a directory, provide the directory path:

./exe -E "pattern" my_directory/

Development

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors