Chapter 4 of the Python version of "Software Design by Example" shows how regex-style pattern matching works, and was inspired by the chapter that Brian Kernighan wrote for "Beautiful Code" almost 20 years ago. third-bit.com/2024/04/04/sdxpy