W3cubDocs

/Nushell

split row for strings

Split a string into multiple rows using a separator.

Signature

> split row {flags} (separator)

Flags

  • --number, -n {int}: Split into maximum number of items
  • --regex, -r: use regex syntax for separator

Parameters

  • separator: a character or regex that denotes what separates rows

Input/output types:

input output
list<string> list<string>
string list<string>

Examples

Split a string into rows of char

>'abc'|split row''
╭───┬───╮
0
1a
2b
3c
4
╰───┴───╯

Split a string into rows by the specified separator

>'a--b--c'|split row'--'
╭───┬───╮
0a
1b
2c
╰───┴───╯

Split a string by '-'

>'-a-b-c-'|split row'-'
╭───┬───╮
0
1a
2b
3c
4
╰───┴───╯

Split a string by regex

>'a   b       c'|split row-r'\s+'
╭───┬───╮
0a
1b
2c
╰───┴───╯

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/split_row.html