Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Practice build · Languages, parsers and algorithms

Build your own Regex Engine

A regular expression engine: a recursive backtracking matcher first, then Thompson's NFA construction, which runs in linear time.

  • Intermediate
  • About 6–12 h
  • 4 checkpoints
  • 4 tutorials · C, JavaScript, Python

Pick a tutorial, then check yourself at each checkpoint. Work in any language you like.

Choose a tutorial

Why build it

Regular expressions power validation, search and log processing. Building two engines shows why some patterns can hang a production system, and how automata avoid it.

You will be able to

  • Parse a regular expression into a syntax tree with correct precedence.
  • Match with recursive backtracking.
  • Compile to an NFA and simulate it in linear time.
  • Explain catastrophic backtracking and how to avoid it.

Skills it exercises

Recommended on Data Structures & Algorithms.

Checkpoints

How you know you are there

Work in any language. Each checkpoint ends with something you can run or observe, so you can check it yourself.

  1. Checkpoint 1Self-check

    Simple matcher

    Done when: Literals, ., ^, $ and * match like grep on a table of 30 test cases.

  2. Checkpoint 2Self-check

    Parser

    Done when: Alternation, groups, +, ? and character classes parse into a syntax tree with correct precedence.

  3. Checkpoint 3Self-check

    NFA

    Done when: Matching (a+)+b against 30 a characters finishes instantly with the NFA, while the backtracking version takes far longer.

  4. Checkpoint 4Self-check

    Lazy DFA

    Done when: States are cached into a lazy DFA, and a benchmark compares the three engines.

Stretch goals

  • Capture groups.
  • Unicode character classes.
Follow a tutorial

Step-by-step guides

Pick one in a language you know (tutorial languages: C, JavaScript, Python). They open on the author’s site.

Practice builds are self-paced: Tech Atlas does not track them or count them as evidence. To show a skill, take its knowledge check from the skill page.

Tutorials come from codecrafters-io/build-your-own-x (CC0, snapshot of 2026-07-14, commit aa17439; links checked on 2026-10-19). Each tutorial belongs to its author and keeps its own licence; Tech Atlas links to it and does not host it. Briefs, checkpoints and the mapping to skills are Tech Atlas editorial drafts.