split "comp.lang.tcl" . → comp lang tcl
See how the split command splits on every character in splitChars, which can result in information loss if you are not careful:
split "alpha beta gamma" "temp" → al {ha b} {} {a ga} {} a
Extract the list words from a string that is not a well-formed list:
split "Example with {unbalanced brace character" → Example with \{unbalanced brace character
Split a string into its constituent characters
split "Hello world" {} → H e l l o { } w o r l d
## Read the file set fid [open /etc/passwd] set content [read $fid] close $fid ## Split into records on newlines set records [split $content "\n"] ## Iterate over the records foreach rec $records { ## Split into fields on colons set fields [split $rec ":"] ## Assign fields to variables and print some out... lassign $fields \ userName password uid grp longName homeDir shell puts "$longName uses [file tail $shell] for a login shell" }
Copyright © 1993 The Regents of the University of California.
Copyright © 1994-1996 Sun Microsystems, Inc.
Licensed under Tcl/Tk terms
https://www.tcl.tk/man/tcl/TclCmd/split.htm