Why a tiny language for text shapes exists
Imagine you have a 4 GB log file and you need every line that mentions an IP address followed by a 5xx HTTP status. You can write a Python script that splits each line, parses the third column, checks if it's an IP, then checks if the status starts with 5. Twenty lines of code, and you'll spend half an hour debugging the column index.
Or you write \b\d+\.\d+\.\d+\.\d+\b.*\b5\d{2}\b and pipe the file through ripgrep. One line. Half a second.
Regular expressions exist for that gap — when the question is "which strings have this shape?", hand-rolled parsing is overkill. Regex is a pattern grammar: a tiny language whose only job is to describe shapes of text.
Three things regex is genuinely good at
Search. "Find every string in this haystack that looks like X." Editors, IDEs, log analyzers, security scanners.
Validation. "Does this whole string look like a valid X?" Form fields, config parsers, route matchers.
Extraction + replacement. "Pull the X out of this string" or "replace every X with Y." Data cleaning, code mods, build scripts.
Notice what's not on that list: parsing nested structures, tracking semantics, anything HTML or JSON. We'll come back to that hard limit at the end of this track.