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.
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.
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.
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.
Groups, captures and alternation
(...) captures pieces, $1 reuses them in replace, | offers choices. Rewrite 2026-06-04 as 04/06/2026 in one move.
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.
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.