Skip to content

Course

Regex & Text Processing

Regular expressions as a professional tool — how backtracking engines execute your patterns, how to write and test them against a real corpus, the Unix pipeline and grok/JSON for production logs, and the judgment call of when a regex is the wrong tool entirely.

13 lessons

Course Q&A

Keep reading

Related articles from the SudoSecurity blog.

Reviews

Enrolled members can rate this course.

No reviews yet.

Engines and Mental Models

How engines execute patterns, how quantifiers and anchors really behave, and why the same regex means different things in different tools.

  1. 01How Regex Engines Actually MatchBacktracking versus automata engines, what a choice point costs, and the mental model that lets you predict a pattern's behavior before you run it.22mOpen
  2. 02Quantifiers, Classes, and Anchors: Saying Exactly What You MeanGreedy, lazy, and possessive quantifiers, why negated classes beat lazy dots, and the anchors that turn 'contains' into 'is'.20mOpen
  3. 03Dialects: BRE, ERE, PCRE, JavaScript, and RE2Why a pattern that works in regex101 silently matches nothing in sed — flavor differences, escaping layers, and leftmost-longest versus leftmost-first.20mOpen
  4. 04Writing a Pattern You Can Prove WorksA mechanical pipeline for shipping a regex: spec sentence first, corpus of positives/negatives/near-misses second, pattern last, timing asserted in CI.18mOpen

Precision Matching

Capture groups, backreferences, lookarounds, flags, and Unicode — extracting exactly what you meant and nothing else.

  1. 01Capture Groups, Backreferences, and ReplacementNumbered and named groups, non-capturing groups, the last-iteration trap, and the replacement syntax that differs in every tool.22mOpen
  2. 02Lookarounds: Matching on Context Without Consuming ItLookahead and lookbehind as zero-width assertions, engine support differences, and when a lookaround is cleverness you should replace with code.20mOpen
  3. 03Flags, Lines, and Unicode: Where Correct Patterns Go WrongMultiline and dotall semantics, the trailing-newline validation bypass, CRLF, code units versus code points, and the stateful g flag.22mOpen
  4. 04Replace with a Function: Computed ReplacementsWhen the replacement depends on the match — String.replace callbacks, re.sub callables, lookup tables, and the cliff edge where a callback becomes a tokenizer.18mOpen

Production Text Processing

Catastrophic backtracking, the Unix text toolkit, and the judgment call of when to stop using regex at all.

  1. 01Catastrophic Backtracking and ReDoSThe pattern shapes that turn a regex into a denial-of-service, the real outages they caused, and the fixes in order of preference.25mOpen
  2. 02Matching Across Lines: Records That Aren't LinesWhen records span lines: awk paragraph mode, slurp flags, rg -U, the m-versus-s distinction, and the bounded-lazy idiom for folded text.20mOpen
  3. 03The Unix Text Toolkit: grep, sed, awk, and jqEach tool's lane, the flags you'll actually use, and the incident-response pipelines that answer questions in seconds instead of scripts.28mOpen
  4. 04Grok, dissect, and the Case for JSON LogsNamed regex patterns in Logstash, Datadog, and Loki; dissect for fixed shapes; and why emitting JSON from the app beats maintaining grok rules.20mOpen
  5. 05Knowing When Not to Use RegexThe formats regex can't parse, the security bugs that come from trying, and a decision checklist for regex versus parser versus pipeline.20mOpen