strip minor improvement (#16444)
* strip minor improvement * add more tests * Update tests/stdlib/tstrutils.nim Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
This commit is contained in:
parent
8d913a5921
commit
417c2509c4
2 changed files with 14 additions and 1 deletions
|
|
@ -2813,7 +2813,7 @@ func strip*(s: string, leading = true, trailing = true,
|
|||
if leading:
|
||||
while first <= last and s[first] in chars: inc(first)
|
||||
if trailing:
|
||||
while last >= 0 and s[last] in chars: dec(last)
|
||||
while last >= first and s[last] in chars: dec(last)
|
||||
result = substr(s, first, last)
|
||||
|
||||
func stripLineEnd*(s: var string) =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue