>perl -wMstrict -le "my @anded = qw(foo bar baz); ;; my $jumbled = join ') (?= .*? ', @anded; $jumbled = qr{ \A (?= .*? $jumbled) }xms; print qq{any order: $jumbled}; ;; my $ordered = join ') .*? (?: ', @anded; $ordered = qr{ (?: $ordered) }xms; print qq{sequential: $ordered}; ;; while (<>) { chomp; print qq{string: '$_'}; print /$jumbled/ ? ' ' : 'no', ' match jumbled'; print /$ordered/ ? ' ' : 'no', ' match ordered'; print ''; } " any order: (?msx-i: \A (?= .*? foo) (?= .*? bar) (?= .*? baz) ) sequential: (?msx-i: (?: foo) .*? (?: bar) .*? (?: baz) ) "foo " string: '"foo "' no match jumbled no match ordered "foo bar ba" string: '"foo bar ba"' no match jumbled no match ordered "foo bar baz" string: '"foo bar baz"' match jumbled match ordered "baz foo bar" string: '"baz foo bar"' match jumbled no match ordered ^Z