split
split string ?splitChars?
split string splitChars -grapheme
Makes a list: it cuts the string at each character of splitChars (white space by default). Two separators in a row give an empty element. An empty splitChars cuts between each character. With -grapheme, the unit is the grapheme cluster: an empty splitChars gives each cluster, and a split character cuts only where it is a whole cluster. The form with -grapheme needs the module ztcl::text in the build.
Examples
A click on an example runs it in the shell of the page.
split "a,b,,c" ,:a b {} csplit abc "":a b cllength [split "e\u0301x" "" -grapheme]:2
Facts
- Capability: none.
- Compute cost: one compute unit for the call, and more for the commands that it runs.
Differences from Tcl 8.6
- The form with
-graphemeis new in ztcl. It has three arguments, so in Tcl it is an error.