split list
for filters> split list {flags} (separator)
--regex, -r
: separator is a regular expression, matching values that can be coerced into a stringseparator
: the value that denotes what separates the listinput | output |
---|---|
list<any> | list<list<any>> |
Split a list of chars into two lists
> [a, b, c, d, e, f, g] |split listd
╭───┬───────────╮
│0│╭───┬───╮│
│││0│a││
│││1│b││
│││2│c││
││╰───┴───╯│
│1│╭───┬───╮│
│││0│e││
│││1│f││
│││2│g││
││╰───┴───╯│
╰───┴───────────╯
Split a list of lists into two lists of lists
> [[1,2], [2,3], [3,4]] |split list [2,3]
╭───┬───────────────────╮
│0│╭───┬───────────╮│
│││0│╭───┬───╮││
│││││0│1│││
│││││1│2│││
││││╰───┴───╯││
││╰───┴───────────╯│
│1│╭───┬───────────╮│
│││0│╭───┬───╮││
│││││0│3│││
│││││1│4│││
││││╰───┴───╯││
││╰───┴───────────╯│
╰───┴───────────────────╯
Split a list of chars into two lists
> [a, b, c, d, a, e, f, g] |split lista
╭───┬───────────╮
│0│╭───┬───╮│
│││0│b││
│││1│c││
│││2│d││
││╰───┴───╯│
│1│╭───┬───╮│
│││0│e││
│││1│f││
│││2│g││
││╰───┴───╯│
╰───┴───────────╯
Split a list of chars into lists based on multiple characters
> [a, b, c, d, a, e, f, g] |split list-r'(b|e)'
╭───┬───────────╮
│0│╭───┬───╮│
│││0│a││
││╰───┴───╯│
│1│╭───┬───╮│
│││0│c││
│││1│d││
│││2│a││
││╰───┴───╯│
│2│╭───┬───╮│
│││0│f││
│││1│g││
││╰───┴───╯│
╰───┴───────────╯
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/split_list.html