SHOW:
|
|
- or go back to the newest paste.
| 1 | - | template cutRight(s: string, charsToCut: int): typed = |
| 1 | + | template cutRight(s: string, charsToCut: Natural): string = |
| 2 | - | s[0..^(charsToCut + 1)] |
| 2 | + | s[0 .. ^(charsToCut + 1)] |
| 3 | ||
| 4 | - | echo cutRight("Hello World", 6)
|
| 4 | + | template cutLeft(s: string, charsToCut: Natural): string = |
| 5 | s[charsToCut .. ^1] | |
| 6 | - | #[ |
| 6 | + | |
| 7 | - | >nim c -r strslice.nim |
| 7 | + | template cutLeftRight(s: string, left, right: Natural): string = |
| 8 | - | Hint: used config file 'C:\Program Files\Nim\config\nim.cfg' [Conf] |
| 8 | + | s[left .. ^(right + 1)] |