Tokenize a string with escaping: Difference between revisions

Renamed "tokenzie" as "tokenize". Minor other changes.
(Ada version)
(Renamed "tokenzie" as "tokenize". Minor other changes.)
Line 2,187:
<lang nim>import streams
 
proc tokenzietokenize(s: Stream, sep: static[char] = '|', esc: static[char] = '^'): seq[string] =
var buff = ""
while not s.atEnd():
let c = readChar s.readChar
case c
of sep:
Line 2,198:
buff.add s.readChar
else:
buff &=.add c
result.add buff
 
for i, s in tokenzietokenize(newStringStream "one^|uno||three^^^^|four^^^|^cuatro|"):
echo i, ":", s
</lang>
Anonymous user