Skip to content

Instantly share code, notes, and snippets.

@Tux
Created November 6, 2015 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tux/0bf175a73e713b2e43e9 to your computer and use it in GitHub Desktop.
Save Tux/0bf175a73e713b2e43e9 to your computer and use it in GitHub Desktop.
use v6;
# string to parse
my Str $str = ',"I said, ""Hi!""",';
# three alternatives for eol, separator, and quote
# as escape is identical to quote, I do not need to repeat
my @re = "\r\n", "\r", "\n", ",", "\"", Str;
my @chunks = $str.split(@re, :k, :skip-empty);
dd $str;
dd @re;
dd @chunks;
=>
Can only :k, :kv, :p when using multiple Cool needles
in block <unit> at split.pl:10
due to the trailing Str in @re
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment