in reply to Why machine-generated solutions will never cease to amaze me

Just for the record, I'd like to point out that there's the module Regex::PreSuf (short for prefix+suffix), which does something similar — namely, combining strings into a single pattern that matches them all:
#! /usr/local/bin/perl -wl use Regex::PreSuf; print presuf(qw(sad salad spread));
It produces:
s(?:al|pre)?ad
Heh. I think you might feel right at home with it. :)

Replies are listed 'Best First'.
Re^2: Why machine-generated solutions will never cease to amaze me
by grinder (Bishop) on Nov 10, 2004 at 16:54 UTC

    Yes, I know about that module. Its biggest shortcoming is that it works on single characters, which makes it pretty useless for applying it to patterns that contain meta-characters.

    For instance, the two patterns foo\d+bar and foo\s+1 will produce foo\\(?:d\+bar|s\+1), and that's not going to match anything the individual patterns match.

    - another intruder with the mooring of the heat of the Perl