use strict; use warnings; use Test::More tests => 1; my $text = 'This is just an arbitrary example of text.'; my $query = qr~(?:(?:This)|(?:That)).*?(just).*?(arbitrary).*?$~; my @want = (qw/just arbitrary/); $text =~ $query; is_deeply \@{^CAPTURE}, \@want;