Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

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:

inputoutput
list<string>list<string>
stringlist<string>

Examples

Split a string into rows of char

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

Split a string into rows by the specified separator

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

Split a string by '-'

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

Split a string by regex

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