>perl -wMstrict -le "use 5.010; ;; my $regex = qr{ (?| (AAA) | (BBB) | (XXX) | (YYY) ) }xms; ;; my $s = 'AAA BBB CCC DDD AAA BBB'; my $n_matches =()= $s =~ m{ $regex }xmsg; print qq{$n_matches matches}; ;; $s = 'foo bar baz boff'; $n_matches =()= $s =~ m{ $regex }xmsg; print qq{$n_matches matches}; " 4 matches 0 matches