Techalicious Academy / 2026-02-19-advanced-regex

(Visit our meetup for more great tutorials)

ADVANCED REGULAR EXPRESSIONS

Welcome back. If you were at Regex Therapy a few weeks ago, you learned the alphabet. You can match digits, words, whitespace. You can anchor patterns to the start or end of a line. You can capture groups and use backreferences in replacements. You know your way around quantifiers.

Tonight we learn to write poetry.

This is PCRE, which stands for Perl Compatible Regular Expressions. Perl invented this extended regex syntax decades ago and the rest of the world adopted it. When you use grep -P on Linux, you're using PCRE. When you write regex in Python, PHP, Ruby, Java, JavaScript, Rust, Go... they all borrowed from PCRE. Some implement more of it than others, but the core ideas are everywhere. Learn this once and it works in every language you touch.

What We're Covering Tonight

Here's the roadmap for tonight. We're going deep on five areas that take your regex from "functional" to "surgical."

  1. Quantifier mastery. You know greedy and non-greedy exist. Tonight you'll understand WHY they behave the way they do, and you'll meet possessive quantifiers, which most people never learn.
  2. Capture groups, the full picture. Named groups, backreferences inside patterns (not just replacements), nested group numbering, and when to use what.
  3. Regex subroutines. This is the feature that blows people's minds. Define a pattern once, call it multiple times. DRY principle applied to regex.
  4. Lookaround assertions. Match based on what comes before or after your target WITHOUT including it in the match. This changes everything.
  5. The full modifier toolkit. You know about /g and /i. There are more, and some of them are incredibly useful.
  6. Tying regex into AI workflows. Using regex to clean data before feeding it to models. Using AI to help you write and debug regex. The practical intersection.

What You Need

Same setup as last time. A terminal. Some text files to practice on. Everything you learned at Regex Therapy, because we're building directly on top of that foundation. If you weren't at the first session, you can still follow along, but some of the basics will move fast.

We'll be using grep -P for most demos tonight because it gives us full PCRE support right in the terminal. If you're on a Mac and grep -P doesn't work, use perl directly:

perl -ne 'print if /your_pattern/' filename

That does the same thing. Perl is PCRE's home turf, so everything works.

For search and replace demos, we'll use perl one-liners:

perl -pe 's/pattern/replacement/flags' filename

Let's get into it.