use Regexp::List qw( ); my @badwords = qw( r rd red ); my $badwords = Regexp::List->new(modifiers=>'i')->list2re(@badwords); # qr/r(?:e?d)?/i