- or download this
$_ = "04abcdefgh";
my $result;
...
}
dd $result; #-> "04abcd"
- or download this
"04abcdefgh" =~ / (\d\d)
(??{ ". {".(0 + $^N)."}" }) /x;
dd $&; #-> "04abcd"
- or download this
"04abcdefgh" =~ / (\d\d)
(?>
...
) /x;
dd $&; #-> "04abcd"
- or download this
"04abcdefgh" ~~ / (\d\d) . ** { $0 } /;
- or download this
"04abcdefgh" ~~ / (\d\d) . ** { $/[*-1] } /;
- or download this
"04abcdefgh" =~ / (\d\d) .{ (?{ $1 }) } /x;
- or download this
"04abcdefgh" =~ / (\d\d) .{ (?{ $^N }) } /x;
- or download this
":aa2bb4cc6dd8" =~ / (:)
(?: (\w\w) (\d) )* /x;
...
dd $1; #-> ":"
dd $2; #-> "dd"
dd $3; #-> 8
- or download this
$_ = ":aa2bb4cc6dd8";
my @result;
...
dd $result[0]; #-> ":aa2bb4cc6dd8"
dd $result[1]; #-> ["aa", "bb", "cc", "dd"]
dd $result[2]; #-> [2, 4, 6, 8]
- or download this
":aa2bb4cc6dd8" =~ / (:)
(?{ [[], []] }) # initialize $^R
...
dd $1; #-> ":"
dd $^R->[0]; #-> ["aa", "bb", "cc", "dd"]
dd $^R->[1]; #-> [2, 4, 6, 8] }
- or download this
":aa2bb4cc6dd8" =~ / (:)
(?{ [] }) # initialize $^R
...
dd $&; #-> ":aa2bb4cc6dd8"
dd $1; #-> ":"
dd $^R; #-> [["aa", 2], ["bb", 4], ["cc", 6], ["dd", 8]]
- or download this
":aa2bb4cc6dd8" ~~ / (":")
[ (\w\w) (\d) ]* /;
...
dd $0.Str; #-> ":"
dd $1».Str; #-> ("aa", "bb", "cc", "dd")
dd $2».Int; #-> (2, 4, 6, 8)
- or download this
use re 'multi_captures';
...
dd $1; #-> ":"
dd $2; #-> ["aa", "bb", "cc", "dd"]
dd $3; #-> [2, 4, 6, 8]