Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Multisplit/Nim/multisplit.nim
Normal file
19
Task/Multisplit/Nim/multisplit.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import strutils
|
||||
|
||||
iterator tokenize(text: string; sep: openArray[string]): tuple[token: string, isSep: bool] =
|
||||
var i, lastMatch = 0
|
||||
while i < text.len:
|
||||
for j, s in sep:
|
||||
if text[i..text.high].startsWith s:
|
||||
if i > lastMatch: yield (text[lastMatch ..< i], false)
|
||||
yield (s, true)
|
||||
lastMatch = i + s.len
|
||||
i += s.high
|
||||
break
|
||||
inc i
|
||||
if i > lastMatch: yield (text[lastMatch ..< i], false)
|
||||
|
||||
for token, isSep in "a!===b=!=c".tokenize(["==", "!=", "="]):
|
||||
if isSep: stdout.write '{',token,'}'
|
||||
else: stdout.write token
|
||||
echo ""
|
||||
Loading…
Add table
Add a link
Reference in a new issue