دنبال کننده ها

۱۳۹۶ آبان ۹, سه‌شنبه

perl6 - Printing parts of match in Perl 6

[ad_1]





When I use a named regex, I can print its contents:



my regex rgx ww ;
my $string = 'abcd';

$string ~~ / <rgx> /;
say $<rgx>; # 「ab」


But if I want to match with :g or :ex adverb, so there is more than one match, it doesn't work. The following



my regex rgx ww ;
my $string = 'abcd';

$string ~~ m:g/ <rgx> /;
say $<rgx>;


gives an error:



Type List does not support associative indexing.
in block <unit> at test1.p6 line 5


How should I modify my code?




[ad_2]

لینک منبع