str substring

Get part of a string. Note that the start is included but the end is excluded, and that the first character of a string is index 0.

Signature

> str substring (range) ...rest

Parameters

  • range: the indexes to substring [start end]
  • ...rest: optionally substring text by column paths

Examples

Get a substring "nushell" from the text "good nushell"

>  'good nushell' | str substring [5 12]

Alternatively, you can use the form

>  'good nushell' | str substring '5,12'

Drop the last n characters from the string

>  'good nushell' | str substring ',-5'

Get the remaining characters from a starting index

>  'good nushell' | str substring '5,'

Get the characters from the beginning until ending index

>  'good nushell' | str substring ',7'