Since this is also my dream, I am afraid that allowing statements within the builder will preclude this eventuality. It's also unfortunate to have regular expression literals having labeled captures (which, in Swift, I guess will happen almost 100% of the times) to break code when converted into a combination of Regex
DSLs and Reference
s. Ideally, you shouldn't do anything after converting a regex literal into its DSL equivalent.
Also, is the current design capable of placing labeled regexes in Regex
DSLs or are labeled tuples not handled by the 10-nple overloads?
Should the transform
closure on Try/Capture
s become a .transform
method on instances of RegexComponent
? It could be useful to be able to try a transformation without actually capturing the value.
Regarding the Structured rather than flat captures final section in the considered alternatives: I'm not sure it's a future-proof decision to split Regex
and an hypothetical Pattern
based on their capture structure and default semantics. If a more powerful, "Swifty" and structured Pattern
is available, would users still use this hybrid Regex
DSL?