[Pitch] Regex Type and Overview

Because we are not forking regex syntax; it would defeat a tentpole rationale for implementing regex syntax if an existing formula that works unambiguously with any other regex engine means a different thing when parsed by Swift’s regex engine. To be concrete:

The regex (a|b)(a|b)\1 matches aba and not abb, because \1 refers to the first capture group and not the second. It would not be acceptable for the same regex to match abb rather than aba in Swift. This much is non-negotiable.

The question at hand is whether .1 in Swift should correspond to \1 in regex syntax, or whether it should be .0 that corresponds to \1 instead. That alternative doesn’t seem like an improvement to me.

8 Likes