Currently the Regex engine is stored in a singleton instead of being passed to where it is used. #32586 also would add more singletons for similar purpose.
This should be cleaned up, and a factory context with the appropriate objects should be passed to all locations that need these singletons.