How I learned to stop worrying and love Regex
summary
Covers concrete PHP regex mechanics: preg_match/PCRE behavior, greedy vs lazy vs possessive quantifiers, and anchors that bite (\$ vs \z). Shows a real composer use case that replaces token_get_all with staged regex filtering to avoid memory blowups, and demonstrates catastrophic backtracking turning millions of steps into ~20 by making repeats possessive. Notes PHP 7’s PCRE JIT speedup, recommends grep -E and the x modifier for readable, named groups, and gives practical limits for matching HTML or nested structures.
AI-written summary · about
chapters (30)
- 0:00Intro
- 1:07History
- 4:08Regex Concepts
- 4:30Pattern Components
- 5:10Character Classes
- 7:40Character Class Shortcuts
- 8:52Dot Metacharacter
- 9:49Subpatterns and Alternations
- 14:25Lazy Quantifiers
- 15:58Possessive Quantifiers
- 18:35Anchors for Validation
- 20:19Back-references to Subpatterns
- 21:54Lookahead & Lookbehind
- 24:12Word boundary metacharacter
- 25:29Conditionals
- 25:59Pattern Delimiters
- 27:50Modifiers
- 28:47Readability
- 33:00Engine Properties
- 39:04PCRE JIT
- 40:24Code Search
- 43:04Stripping Remove a prefix if it's present
- 43:48Stripping PHP files to bits
- 46:50Splitting
- 47:17grep
- 48:08Does it match?
- 50:03Limitations
- 51:07Domain
- 52:45Boundaries
- 53:17Document
related talks
39mRegex-Fu
57mRegular Expressions, To Match Or Not, That is the Question
38mEscape from Planet Regex - Kotlin to the Rescue
22mRegex in PowerShell: How to grasp it and why you should grasp it
04mThree indispensable REGEX hacks
34mAn Intuitive Grasp of RegEx’s in Python
12m10 Awesome things that most people won't notice in PHP
20mBuild your own Swift Regex: A Gentle Introduction to Swift Regex
