my @patterns = qw(-[45j]{2} [1-3][a46]u); my $pat_string = join "|", @patterns; if ($MType =~ /^$pat_string/oi) { # do stuff }