use strict; use warnings; my @strings = ( q{catFiSHcake}, q{DogFISHcAkE}, q{cATfishCake}, q{caTFISHcaKE}); my $rxMixed = qr {(?xi) # use extended syntax and # make case insensitive (?:cat|dog) # non-capture alternation # of cat or dog (?-i:FISH) # FISH, case sensitive # inside parentheses cake # cake, case insensitive # again }; foreach my $string ( @strings ) { print qq{$string: }, $string =~ $rxMixed ? qq{Match\n} : qq{No match\n}; }