Help for this page

Select Code to Download


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