fork download
  1. #!/usr/bin/perl6
  2. # your code goes here
  3.  
  4. Str.^find_method("split").wrap(
  5. sub split(|c) {
  6. my @x = callwith(|c); # call Str::split with all arguments
  7. my @r = [];
  8. my ($i, $j) = (0, 0);
  9. my regex letter-number { <[a..z0..9]> }
  10.  
  11. for @x -> $x {
  12. if $x.lc ~~ /<letter-number>/ && $i > 0 && @r[$i-1].lc ~~ /<letter-number>/ {
  13. @r[$i-1] ~= $x;
  14. } else {
  15. @r[$i++] = $x;
  16. }
  17. }
  18. @r;
  19. });
  20.  
  21. my $ms = "为了让大家在 V2EX 上的时间更有效率";
  22.  
  23. say $ms;
  24.  
  25. say $ms.split("").join("===");
Success #stdin #stdout 0.24s 80852KB
stdin
Standard input is empty
stdout
为了让大家在 V2EX 上的时间更有效率
===为===了===让===大===家===在=== ===V2EX=== ===上===的===时===间===更===有===效===率===