This is pretty cool!
Are there real-world uses for this? Or is it just a toy? It looks like it can optimize for size, which is nice.
I would say it’s a toy. It converts a set of strings to a regex, but it can only do exact matching on items in that set. There’s no way to feed it a bunch of strings ending with .txt and have it generalize to .*\.txt, for example, which is what most people seem to want from regex generators.
It’s the same result as generating a regex via "|".join(strlist). A bit smarter, but equivalent in power. In most places where you could use this, I’d say you’re better off with constructing a hash set and checking membership that way.