I think it's a useful future direction! However, I wanted to clarify two things:
Regex
's underlying representation is not the textual regex, but a general-purpose pattern matching program (for efficiency). So obtaining a textual regex fromRegex
would be a conversion.- Not every
Regex
built with regex builder can be converted to a textual regex. Regex builder supports arbitrary types that conform to theRegexComponent
protocol, includingCustomMatchingRegexComponent
(pitched in regex-powered string processing algorithms) which can be implemented with arbitrary code. If aRegex
contains aCustomMatchingRegexComponent
, it cannot be converted to a textual regex.