in reply to Multiple Match (Sort of AND)

Generating a regex is easier than hand coding.

And far easier than hand-coding re and re and re and ... once you get beyond half a dozen or so.

This generates two res, one just tests if all the elements are present. The other both tests for them, and captures those that are matched:

#! perl -slw use strict; my $re = join'', map{ "(?=^.*$_)" } qw[ scan print rinse repeat ]; my $re2 = join'', map{ "(?=^.*($_))?" } qw[ scan print rinse repeat ]; chomp( my @tests = <DATA> ); print "Just test"; for( @tests ){ printf "$_: %s\n", $_ =~ $re ? 'matched' : 'no match'; } print "\nTest and what"; for( @tests ){ my @matched = grep defined, $_ =~ $re2; printf "$_: %s\n", @matched ? "matched: [@matched]" : 'no match'; } __DATA__ scan and print and rinse and repeat print and scan and rinse and repeat print and scan and rinse print fred

Output:

C:\test>junk44 Just test scan and print and rinse and repeat: matched print and scan and rinse and repeat: matched print and scan and rinse: no match print: no match fred: no match Test and what scan and print and rinse and repeat: matched: [scan print rinse repeat +] print and scan and rinse and repeat: matched: [scan print rinse repeat +] print and scan and rinse: matched: [scan print rinse] print: matched: [print] fred: no match

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy