Regular Expressions

The regex constructs you actually use.

Regular Expressions is taught here in 13 lessons, running from Regular expressions basics through to When not to use regex. Each lesson takes one topic, shows the working code, and links onward to the next, so the course can be read straight through in order.

TrackComputer Science Fundamentals
Lessons13
LevelBeginner to intermediate
Reading timeabout 3 hours
PrerequisitesHelpful, but not required: Dates & Time

Lessons

  1. Regular expressions basicsThe handful of regex constructs you actually use daily, with runnable examples and the mistakes that bite beginners.
  2. Character classes, quantifiers and anchorsBuild patterns out of ranges, shorthands and counted repeats, and control exactly where a match is allowed to start and end.
  3. Groups, captures and backreferencesUse parentheses to capture parts of a match, name them for readability, and refer back to text the pattern already matched.
  4. Lookahead and lookbehindAssert what must come before or after a match without including it, and build validation patterns that stay readable.
  5. Flags and matching modesHow global, case-insensitive, multiline, dotAll, Unicode and sticky modes change a match, and where to put them.
  6. Regex in JavaScriptThe literal and constructor forms, the match API you actually use, replacements with groups, and the global lastIndex trap.
  7. Regex in PythonThe re module: search, match and fullmatch, findall against finditer, group access, compiled patterns, and raw strings.
  8. Dialects and engines: PCRE, POSIX, RE2 and .NETWhy the same pattern behaves differently in different tools, and how to write patterns that survive a move between engines.
  9. Practical patterns: validation, logs and URLsRealistic patterns for the values people actually validate and extract, and an honest account of where each one stops being enough.
  10. Text surgery: find and replace across a codebaseDrive editor and command-line replacements with capture groups, preview the diff before writing, and reduce the risk of a bulk edit.
  11. Greedy, lazy and catastrophic backtrackingHow the engine searches, why nested quantifiers explode, and the practical defences against a pattern that hangs on hostile input.
  12. Unicode and character propertiesCode points against code units, the u and v flags, property escapes for scripts and categories, and normalising text before matching.
  13. When not to use regexRecognise the inputs a regular expression cannot handle, and pick the parser, schema or state machine that can.

More in Computer Science Fundamentals

Algorithms Data Structures Computer Networks Operating Systems Character Encodings Hashing & Checksums Data Formats Dates & Time

FAQ

How long does the Regular Expressions course take?
It has 13 lessons, about 3 hours of reading. Expect roughly twice that if you type out and run every example.
Do I need prior experience for Regular Expressions?
Not strictly. It helps to have read Dates & Time first, because some lessons build on it, but every lesson explains its own assumptions.
What should I read after Regular Expressions?
This is the last course in Computer Science Fundamentals right now. Browse the other tracks from the courses index to go sideways.

Last refreshed 2026-09-18.