university levels of education Regular Expressions I — V
One subject taken all the way down, in nine courses — handmade, no ads, no sign-ups. A hundred and twenty-five long lectures with runnable code and typeset mathematics throughout: the first five build the pattern language itself, the next four turn it into real parsers — text to JSON, tokenisers, recursive descent, streaming and error recovery — and the last lecture explains, in depth, how the parsers behind this whole site were designed and what testing caught. Worked examples revealed step by step, practice with answers, quizzes for every lecture, and unsolved problems to do on your own, in twenty ways of studying including a live regex lab and a continuous read of a whole course.
- 001
Regex I
Foundations: Patterns, Literals, Classes, Quantifiers and Anchors. What a regular expression is, in programming and in formal-language terms; the three questions the `re` module answers — search anywhere, match at the start, match the whole string; raw strings and the twelve metacharacters that need escaping; character classes with ranges, negation and the shorthands; every quantifier including bounded repetition; and the anchors and word boundaries that stop a pattern matching inside the wrong word. Five deep lectures. Every lecture carries the full written explanation with runnable code and typeset mathematics throughout, a reference table of the constructs that matter, defined terms, worked examples revealed step by step, practice problems with their complete solutions, a quiz, and unsolved problems to do on your own, studied through nineteen modes, from flashcards and drills to timed exams and a continuous read of the whole course as one page.
live - 002
Regex II
Structure: Groups, Alternation, Boundaries and Greediness. Capturing groups, named groups and the non-capturing form, with the extraction habits they enable; alternation and its notoriously low precedence, including the anchor trap that catches everyone once; boundaries and zero-width assertions applied to real documents; and the greedy-versus-lazy question, with backtracking explained and the negated character class that usually beats both. Five deep lectures. Every lecture carries the full written explanation with runnable code and typeset mathematics throughout, a reference table of the constructs that matter, defined terms, worked examples revealed step by step, practice problems with their complete solutions, a quiz, and unsolved problems to do on your own, studied through nineteen modes, from flashcards and drills to timed exams and a continuous read of the whole course as one page.
live - 003
Regex III
Assertions: Alternation Design, Lookahead and Lookbehind. Designing alternations as decision trees with common prefixes factored out; positive and negative lookahead, including the stacked-lookahead idiom that expresses AND; lookbehind with Python's fixed-width restriction and the capture-instead workaround; and the two combined into context windows, custom boundaries and overlapping matches. Four deep lectures. Every lecture carries the full written explanation with runnable code and typeset mathematics throughout, a reference table of the constructs that matter, defined terms, worked examples revealed step by step, practice problems with their complete solutions, a quiz, and unsolved problems to do on your own, studied through nineteen modes, from flashcards and drills to timed exams and a continuous read of the whole course as one page.
live - 004
Regex IV
Memory and Transformation: Backreferences, Substitution and Flags. Backreferences for repeated text, duplicate detection and matching delimiters, with the theory note that they take regex beyond regular languages; zero-width assertions used for pure insertion; substitution with `re.sub` and `re.subn`, group references and replacement functions; and the flags — IGNORECASE, MULTILINE, DOTALL and the VERBOSE mode that makes a long pattern reviewable. Five deep lectures. Every lecture carries the full written explanation with runnable code and typeset mathematics throughout, a reference table of the constructs that matter, defined terms, worked examples revealed step by step, practice problems with their complete solutions, a quiz, and unsolved problems to do on your own, studied through nineteen modes, from flashcards and drills to timed exams and a continuous read of the whole course as one page.
live - 005
Regex V
Engineering: Context, Logic, Performance and Real Systems. Lookarounds at depth for filtering and context-sensitive extraction; relational matching and group logic, including the None-versus-empty distinction; performance engineering with catastrophic backtracking and ReDoS, and how to bound patterns that read untrusted input; real parsing, log analysis and validation pipelines with their division of labour; and a capstone on mental models, testing and knowing when to stop using regex at all. Six deep lectures. Every lecture carries the full written explanation with runnable code and typeset mathematics throughout, a reference table of the constructs that matter, defined terms, worked examples revealed step by step, practice problems with their complete solutions, a quiz, and unsolved problems to do on your own, studied through nineteen modes, from flashcards and drills to timed exams and a continuous read of the whole course as one page.
live - 006
Regex VI
Text to JSON: Reading, Matching, Extracting and Storing. The complete pipeline built from nothing — reading a lecture file into Python, recognising headings with a pattern, extracting each record with capture groups, converting to JSON and reading it back; then named groups, optional and missing metadata, two-stage parsing, extracting embedded formulas, validating what was found, and a full parser that puts every piece together. Eleven deep lectures. Every lecture carries the full written explanation with runnable code throughout, a reference table, defined terms, practice problems with answers, a quiz, and unsolved problems to do on your own, studied through nineteen modes including a continuous read of the whole course.
live - 007
Regex VII
Beyond Patterns: State, Structure, Cleaning and Diagnostics. Where regular expressions stop being enough — stateful parsing when a pattern cannot remember; nested numbered sections and multiline metadata with continuation lines; substitution used to clean genuinely noisy files; tokenisation as a discipline; diagnostics that report a line number instead of failing silently; versioned JSON schemas; and building a search index over the result. Nine deep lectures. Every lecture carries the full written explanation with runnable code throughout, a reference table, defined terms, practice problems with answers, a quiz, and unsolved problems to do on your own, studied through nineteen modes including a continuous read of the whole course.
live - 008
Regex VIII
Compiler Techniques: Tokens, Grammars, Trees and Evaluation. The step from pattern matching to parsing proper — recursive analysis of a syntax tree and rewriting it; handling embedded code and mathematics safely; finite-state machines driven by regular expressions; recursive-descent parsing of a small language; backreferences and lookarounds in validation; master token patterns; and a parser that emits typed JSON. Twenty-three deep lectures. Every lecture carries the full written explanation with runnable code throughout, a reference table, defined terms, practice problems with answers, a quiz, and unsolved problems to do on your own, studied through nineteen modes including a continuous read of the whole course.
live - 009
Regex IX
Industrial Practice: Streaming, Recovery, Indentation and Design. Parsing at production scale — streaming large files with iterators, generators, lookahead and pushback; source maps and error recovery with synchronisation and partial trees; indentation-aware stack parsing with parent-child structure; then two closing lectures written for this site: a notation reference for the mathematics used throughout, and a deep walkthrough of how the three parsers behind these courses were designed, including the bugs that only testing found. Fifty-seven deep lectures. Every lecture carries the full written explanation with runnable code throughout, a reference table, defined terms, practice problems with answers, a quiz, and unsolved problems to do on your own, studied through nineteen modes including a continuous read of the whole course.
live - 010
The whole of regular expressions
All nine courses opened as one book — a hundred and twenty-five deep lectures from the first pattern to production parser design, readable end to end in the continuous view or studied through any of the nineteen modes across the whole sequence at once.
live