mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-02 11:12:37 +00:00
14 lines
520 B
Nim
14 lines
520 B
Nim
import unittest
|
|
include nre
|
|
|
|
suite "string splitting":
|
|
test "splitting strings":
|
|
check("12345".split(initRegex("")) == @["1", "2", "3", "4", "5"])
|
|
check("1 2 3 4 5 6 ".split(initRegex(" ", "S")) == @["1", "2", "3", "4", "5", "6", ""])
|
|
check("1 2 ".split(initRegex(" ", "S")) == @["1", "", "2", "", ""])
|
|
check("1 2".split(initRegex(" ", "S")) == @["1", "2"])
|
|
check("foo".split(initRegex("foo")) == @["", ""])
|
|
|
|
test "captured patterns":
|
|
check("12".split(re"(\d)") == @["", "1", "", "2", ""])
|