Build your own Swift Regex: A Gentle Introduction to Swift Regex
summary
Swift regex engine still lacks features like lookbehind and is hard to change, so this session implements concatenation alternation repetition in a tiny Swift engine that compiles a recursive‑descent AST to bytecode and runs a VM‑based backtracker. The uploader’s repo contains the actual Swift code on GitHub repo, the demo shows step‑by‑step execution, and performance notes quantify backtracking differences (e.g. 32 vs 14 steps, 10 vs 2 backtracks) and a 5x speedup for a non‑backtracking pattern.
AI-written summary · about
chapters (8)
- 0:00Introduction to regex
- 1:34Three fundamental operations
- 4:46Parsing and architecture
- 7:01Compiling to bytecode
- 8:07Matching and backtracking
- 13:56Implementing repetition
- 16:36Writing efficient regex
- 19:23Conclusion and resources
related talks
38mEscape from Planet Regex - Kotlin to the Rescue
38mCompilers aren’t magic, so let’s build one in Swift
34mAn Intuitive Grasp of RegEx’s in Python
33mMaking Your Own Tools Using SwiftSyntax
46mHacking With Swift
27mAST Meta-programming
06mFundamentals for Building Convenience with SwiftSyntax
39mRegex-Fu
