Loading...

Build your own grep

Learn about regex syntax: character classes, quantifiers and more

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

Build your own grep is free this October.

The core challenge experience is completely free this month. If you'd like to enjoy advanced features such as running turbo tests, dark mode, or unlimited code examples, you'll need a membership.

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

Match zero or more times
Login via GitHub to view this stage
Match exactly n times
Login via GitHub to view this stage
Match at least n times
Login via GitHub to view this stage
Match between n and m times
Login via GitHub to view this stage