str trim
for strings
Trim whitespace or specific character.
Signature
> str trim ...rest --char --left --right
Parameters
...rest
: For a data structure input, trim strings at the given cell paths--char {string}
: character to trim (default: whitespace)--left
(-l)
: trims characters only from the beginning of the string--right
(-r)
: trims characters only from the end of the string
Input/output types:
input | output |
---|---|
list<string> | list<string> |
record | record |
string | string |
table | table |
Examples
Trim whitespace
> 'Nu shell ' | str trim
Nu shell
Trim a specific character
> '=== Nu shell ===' | str trim -c '=' | str trim
Nu shell
Trim whitespace from the beginning of string
> ' Nu shell ' | str trim -l
Nu shell
Trim a specific character
> '=== Nu shell ===' | str trim -c '='
Nu shell
Trim whitespace from the end of string
> ' Nu shell ' | str trim -r
Nu shell
Trim a specific character
> '=== Nu shell ===' | str trim -r -c '='
=== Nu shell