Scratchpad

A place to write down my thoughts as I work through a particular problem.


Scratchpad: Lookbehinds via reverse matching
Jun 12, 2024 • 2 minute(s)

A month or two ago I discovered that Swift’s fancy new regex builder and regex literals didn’t support lookbehinds, a feature I wanted for a project I’m working on. I decided to see what it would take to implement it myself and slowly worked my way to a (sort-of) (mostly) working initial implementation. Michael Ilseman (one of the original authors of the Swift 5. 7 regex work) has been kindly giving me pointers that were essential for getting as far as I have. In his eyes, the core concept behind lookbehinds, is reverse matching. This is the focus of this scratchpad.

Continue reading ...