W3cubDocs

/Nushell

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:

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

Examples

Split the string into a list of characters

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

Split on grapheme clusters

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

Split multiple strings into lists of characters

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

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