W3cubDocs

/Nushell

split words for strings

Split a string's words into separate rows.

Signature

> split words {flags}

Flags

  • --min-word-length, -l {int}: The minimum word length
  • --grapheme-clusters, -g: measure word length in grapheme clusters (requires -l)
  • --utf-8-bytes, -b: measure word length in UTF-8 bytes (default; requires -l; non-ASCII chars are length 2+)

Input/output types:

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

Examples

Split the string's words into separate rows

>'hello world'|split words
╭───┬───────╮
0hello
1world
╰───┴───────╯

Split the string's words, of at least 3 characters, into separate rows

>'hello to the world'|split words-l3
╭───┬───────╮
0hello
1the
2world
╰───┴───────╯

A real-world example of splitting words

>http gethttps://www.gutenberg.org/files/11/11-0.txt|str downcase|split words-l2|uniq-c|sort-bycount--reverse|first10

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