parent
ed8b4befbf
commit
518c72e57a
1 changed files with 5 additions and 2 deletions
|
|
@ -1941,9 +1941,9 @@ proc strip*(s: string, leading = true, trailing = true,
|
|||
e_i = l_i - 1
|
||||
break
|
||||
dec(i)
|
||||
let newLen = e_i - s_i
|
||||
let newLen = e_i - s_i + 1
|
||||
result = newStringOfCap(newLen)
|
||||
if e_i > s_i:
|
||||
if newLen > 0:
|
||||
result.add s[s_i .. e_i]
|
||||
|
||||
proc repeat*(c: Rune, count: Natural): string {.noSideEffect,
|
||||
|
|
@ -2161,6 +2161,9 @@ when isMainModule:
|
|||
doAssert s.split(' '.Rune, maxsplit = 1) == @["", "this is an example "]
|
||||
|
||||
block stripTests:
|
||||
doAssert(strip("") == "")
|
||||
doAssert(strip(" ") == "")
|
||||
doAssert(strip("y") == "y")
|
||||
doAssert(strip(" foofoofoo ") == "foofoofoo")
|
||||
doAssert(strip("sfoofoofoos", runes = ['s'.Rune]) == "foofoofoo")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue