Merge branch 'devel' of github.com:nim-lang/Nim into devel
This commit is contained in:
commit
0f9d746da5
2 changed files with 21 additions and 0 deletions
|
|
@ -808,6 +808,8 @@ proc split*(s: string, sep: string, maxsplit: int = -1): seq[string] {.noSideEff
|
|||
##
|
||||
## Substrings are separated by the string `sep`. This is a wrapper around the
|
||||
## `split iterator <#split.i,string,string>`_.
|
||||
doAssert(sep.len > 0)
|
||||
|
||||
accumulateResult(split(s, sep, maxsplit))
|
||||
|
||||
proc rsplit*(s: string, seps: set[char] = Whitespace,
|
||||
|
|
|
|||
19
tests/stdlib/tsplit2.nim
Normal file
19
tests/stdlib/tsplit2.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
discard """
|
||||
file: "tsplit2.nim"
|
||||
output: "true"
|
||||
"""
|
||||
import strutils
|
||||
|
||||
var s = ""
|
||||
for w in split("|abc|xy|z", {'|'}):
|
||||
s.add("#")
|
||||
s.add(w)
|
||||
|
||||
try:
|
||||
discard "hello".split("")
|
||||
echo "false"
|
||||
except AssertionError:
|
||||
echo "true"
|
||||
|
||||
#OUT true
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue