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 chars for strings

Split a string into a list of characters.

Signature

> split chars {flags}

Flags

  • --grapheme-clusters, -g: split on grapheme clusters
  • --code-points, -c: split on code points (default; splits combined characters)

Input/output types:

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

Examples

Split the string into a list of characters

> 'hello' | split chars
╭───┬───╮
│ 0 │ h │
│ 1 │ e │
│ 2 │ l │
│ 3 │ l │
│ 4 │ o │
╰───┴───╯

Split on grapheme clusters

> '🇯🇵ほげ' | split chars --grapheme-clusters
╭───┬────╮
│ 0 │ 🇯🇵 │
│ 1 │ ほ │
│ 2 │ げ │
╰───┴────╯

Split multiple strings into lists of characters

> ['hello', 'world'] | split chars
╭───┬───────────╮
│ 0 │ ╭───┬───╮ │
│   │ │ 0 │ h │ │
│   │ │ 1 │ e │ │
│   │ │ 2 │ l │ │
│   │ │ 3 │ l │ │
│   │ │ 4 │ o │ │
│   │ ╰───┴───╯ │
│ 1 │ ╭───┬───╮ │
│   │ │ 0 │ w │ │
│   │ │ 1 │ o │ │
│   │ │ 2 │ r │ │
│   │ │ 3 │ l │ │
│   │ │ 4 │ d │ │
│   │ ╰───┴───╯ │
╰───┴───────────╯