RosettaCodeData/Task/Tokenize-a-string-with-escaping/Arturo/tokenize-a-string-with-escaping.arturo
2023-07-01 13:44:08 -04:00

22 lines
334 B
Text

tokenize: function [s sep esc][
escaping: 0
loop 0..(size s)-1 [i][
chr: get split s i
if? escaping=1 [
prints chr
escaping: 0
]
else [
case [chr]
when? [=sep] [print ""]
when? [=esc] [escaping: 1]
else [prints chr]
]
]
print ""
]
str: "one^|uno||three^^^^|four^^^|^cuatro|"
tokenize str "|" "^"