Skip to content

Build Your Own Regex Engine

Build a regex engine from first principles — literal matching, character classes, quantifiers, anchors, alternation, capture groups. You'll implement Thompson's NFA construction (1968!) and the parallel simulation algorithm that guarantees linear time. By the end you'll understand what makes RE2, Go's regexp, and Rust's regex crate fast and safe.

intermediate16 lessons4 chapters16 graded exercisesPython

No sign-up needed for lesson 1 · certificate on completion · sign up to save progress

What you’ll have built

Chapter by chapter. Every step is a graded exercise.

  • Basic Matching
  • Quantifiers & Anchors
  • NFA Construction & Simulation
  • Production Features
Starts in Python — solve in the language you choose in the editor, same tests either way.

Curriculum

4 chapters, 16 lessons. Each lesson is a short read, one graded exercise, and a quiz.

  1. 1Literal Substring MatchingRead · exercise · quiz
  2. 2Metacharacters: . \d \w \sRead · exercise · quiz
  3. 3Character Classes [abc] and [a-z]Read · exercise · quiz
Loading reference solution…