Since the regex is deterministic from the patterns/Patterns, it might as well be compiled once, at whatever time the properties are set.
Can then return the string or pattern object from the property, from a private var, and the generated regex pattern strings could also be stored in various ways, internally.
However: Since the regex pattern compilation at this point has two flags that change the capture-group insertion behavior, pre-compilation of the patterns may be more convoluted than would be useful.
Since the regex is deterministic from the patterns/
Pattern
s, it might as well be compiled once, at whatever time the properties are set.Can then return the string or pattern object from the property, from a private var, and the generated regex pattern strings could also be stored in various ways, internally.