REGEX THERAPY - OVERVIEW
Why Regex Matters
Regular expressions look like gibberish. That's the first thing everyone thinks. They see something like this:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
And their brain says "nope."
Here's the secret: you don't need to write monsters like that. Most real-world regex is simple. Five or six characters that save you hours of tedious work. Once you learn the basics, you'll wonder how you ever lived without them.
What We're Actually Doing
This tutorial teaches you regex through three practical tools:
- ack - Search files for patterns (like grep, but better)
- rename - Bulk rename files with patterns
- perl - One-liner text transformations
All three use the same regex syntax. Perl-compatible regular expressions (PCRE). Learn it once, use it everywhere.
+-----------+ +-----------+ +-----------+
| | | | | |
| ack | | rename | | perl |
| | | | | |
+-----+-----+ +-----+-----+ +-----+-----+
| | |
| | |
+--------+----------+----------+--------+
| |
v v
Same Regex Same Regex
Syntax Syntax
The AI Connection
If you're running local AI, you're generating a lot of output that needs processing:
- Vision models return messy, variable text
- Image generators create files with ugly default names
- Batch processing means hundreds of files to organize
- Log files full of data that needs extracting
Regex is the glue. It's how you parse AI output, rename generated files, and extract the data you actually need. This is foundation work for everything we do with local AI pipelines.
What You'll Learn
By the end of this tutorial, you'll know how to:
- Search your entire project for specific patterns
- Find all files containing a word (or NOT containing it)
- Rename hundreds of files in one command
- Extract data from messy text
- Do find-and-replace on steroids
We start simple. Single characters. Then we build up to patterns that would take you forever to do by hand.
What You Need
- A terminal (Mac, Linux, or Windows with WSL)
- A folder with some files to practice on
- About an hour of focused time
We'll install the tools as we go.
How This Tutorial is Organized
- Overview (you are here)
- Installing the Tools
- Regex Fundamentals - The Building Blocks
- Regex Fundamentals - Combining Patterns
- ack - Searching Like a Pro
- ack - Advanced Techniques
- rename - Bulk File Operations
- rename - Pattern Capture Magic
- Perl One-Liners - The Basics
- Perl One-Liners - Real World Examples
- Quick Reference Card
- Practice Exercises
Each section builds on the last. Don't skip ahead.