I'm not entirely sure if this is the correct answer, but if you define your
own custom character class
with a 'regex' object, you can use that in the grouping.
sub matching_chars(Str $chars_to_match, Str $_) {
my regex x { $chars_to_match ** 1 };
m/<[]>/;
}
The above worked for me in the
I found something easy in Perl 5 that's puzzling me in Perl 6- specifying a
character class via a variable.
Perl 5:
sub matching_chars {
(my $chars_to_match, local $_) = @_;
/([$chars_to_match]+)/
}
say matching_chars('24680', '19584203'); # says 8420
say matching_chars('+\/\]\[', 'Apple ][+/