Loading...

Build your own grep

Learn about regex syntax: character classes, quantifiers and more

Start Building
grep
C++
grep
Go
grep
Haskell
grep
Rust
grep
C#
grep
TypeScript
grep
Zig
grep
Gleam
grep
Java
grep
JavaScript
grep
Kotlin
grep
Odin
grep
PHP
grep
Python

This challenge requires a CodeCrafters Membership.

You're welcome to study the full challenge structure and stage instructions for free. A membership is needed for submitting code and viewing solutions.

Want to try a free challenge? Try Build your own Kafka — it's free during beta.

Regular expressions (or Regexes) are patterns used to match character combinations in strings. In this challenge, you'll build a Regex engine from scratch by recreating grep, a CLI tool for regex-based searching.

Along the way you'll learn about Regex syntax, character classes, quantifiers and more.

Stages

Match a literal character
Login via GitHub to view this stage
Match digits
Login via GitHub to view this stage
Match word characters
Login via GitHub to view this stage
Positive Character Groups
Login via GitHub to view this stage
Negative Character Groups
Login via GitHub to view this stage
Combining Character Classes
Login via GitHub to view this stage
Start of string anchor
Login via GitHub to view this stage
End of string anchor
Login via GitHub to view this stage
Match one or more times
Login via GitHub to view this stage
Match zero or one times
Login via GitHub to view this stage
Wildcard
Login via GitHub to view this stage
Alternation
Login via GitHub to view this stage

Backreferences

Single Backreference
Login via GitHub to view this stage
Multiple Backreferences
Login via GitHub to view this stage
Nested Backreferences
Login via GitHub to view this stage

File Search

Search a single-line file
Login via GitHub to view this stage
Search a multi-line file
Login via GitHub to view this stage
Search multiple files
Login via GitHub to view this stage
Recursive search
Login via GitHub to view this stage

Quantifiers

Zero or more times
Login via GitHub to view this stage
Exact repetition
Login via GitHub to view this stage
Minimum repetition
Login via GitHub to view this stage
Range repetition
Login via GitHub to view this stage