One way would be with @{^CAPTURE}.
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;
You will need Perl 5.25.7 or newer for this approach but TIMTOWTDI.
🦛
In reply to Re: Highlighting only captured groups from larger regex
by hippo
in thread Highlighting only captured groups from larger regex
by Polyglot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |