Loading...

Build your own grep

Learn about regex syntax: character classes, quantifiers and more

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

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
Match digits
Match alphanumeric characters
Positive Character Groups
Negative Character Groups
Combining Character Classes
Start of string anchor
End of string anchor
Match one or more times
Match zero or one times
Wildcard
Alternation

Backreferences

Single Backreference
Multiple Backreferences
Nested Backreferences

File Search

Search a single-line file
Search a multi-line file
Search multiple files
Recursive search