6 lessons · 60 min Beginner

Regex — the language of patterns, learned by doing

Match, extract, replace text. Every lesson is a lab: your pattern must match the right strings, and you watch the matches light up live.

FR EN
Progress 0/6
1

The pattern: matching text

A regex describes a pattern. Literals, the dot that matches almost anything, and why a real dot needs \. Your first live-highlight lab.

9 min
2

Character classes

[abc], ranges [a-z], the \d \w \s shortcuts and negation [^...]. Picking ONE character from a set, and how that differs from groups.

10 min
3

Quantifiers and greediness

* + ? {n,m}: repeating a pattern. And THE regex trap: the greedy .* that swallows too much, shown live before you learn to tame it.

11 min
4

Anchors and boundaries

^ and $ to anchor at start and end, \b to match a whole word, and the m flag that changes everything on multi-line text.

9 min
5

Groups, captures and alternation

(...) captures pieces, $1 reuses them in replace, | offers choices. Rewrite 2026-06-04 as 04/06/2026 in one move.

10 min
6

Regex in JavaScript for real

test, match, matchAll, replace, the g i m s u flags. The email humility lesson, and the two don'ts: parsing HTML, and exploding patterns.

11 min

What you will learn

Read and write a pattern: literals, [abc] \d \w classes, escaping

Repeat with * + ? {n,m} and tame greediness (the regex trap number one)

Capture with (...) and reuse with $1: extract and rewrite text

Use regex in JS (test, match, replace) knowing their limits (email, HTML)

Prerequisites: JavaScript basics help for the last lesson, but the patterns themselves require nothing. The lab runs on your browser's real regex engine. Nothing to install.

Start lesson 1

Free · No signup · 9 minutes