Created
November 5, 2015 20:14
-
-
Save Tux/41263465dcb3b12ded2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", ",", "\""; | |
my @chunks = $str.split(@re, :keep-indices, :skip-empty); | |
dd $str; | |
dd @re; | |
dd @chunks; | |
with skip-empty | |
Str $var = ",\"I said, \"\"Hi!\"\"\"," | |
Array $var = $["\r\n", "\r", "\n", ",", "\""] | |
Array $var = $["I said", 3, " ", 4, "Hi!", 4] | |
without skip-empty | |
Str $var = ",\"I said, \"\"Hi!\"\"\"," | |
Array $var = $["\r\n", "\r", "\n", ",", "\""] | |
Array $var = $["", 3, "", 4, "I said", 3, " ", 4, "", 4, "Hi!", 4, "", 4, "", 4, "", 3, ""] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment