Optimized self creation of regex