I was asked today if there was a library to take a list of strings and to compute the most efficient regex to match only those strings. I think it\'s an NP Complete problem by i
The Regex::PreSuf module is designed to do exactly this.
To quote the Synopsis:
use Regex::PreSuf; my $re = presuf(qw(foobar fooxar foozap)); # $re should be now 'foo(?:zap|[bx]ar)'