1mNAME0m
       split - Split a string into a proper Tcl list

1mSYNOPSIS0m
       1msplit 4m22mstring24m ?4msplitChars24m?


1mDESCRIPTION0m
       Returns a list created by splitting 4mstring24m at each character that is in
       the 4msplitChars24m argument.  Each element of the result list will  consist
       of the characters from 4mstring24m that lie between instances of the charac-
       ters in 4msplitChars24m.  Empty list elements will be  generated  if  4mstring0m
       contains  adjacent  characters  in  4msplitChars24m, or if the first or last
       character of 4mstring24m is in 4msplitChars24m.  If 4msplitChars24m is an empty string
       then  each character of 4mstring24m becomes a separate element of the result
       list.  4mSplitChars24m defaults to the standard white-space characters.

1mEXAMPLES0m
       Divide up a USENET group name into its hierarchical components:
              1msplit 22m"comp.lang.tcl.announce" .
                   4m=>24m 4mcomp24m 4mlang24m 4mtcl24m 4mannounce0m

       See how the 1msplit 22mcommand splits  on  4mevery24m  character  in  4msplitChars24m,
       which can result in information loss if you are not careful:
              1msplit 22m"alpha beta gamma" "temp"
                   4m=>24m 4mal24m 4m{ha24m 4mb}24m 4m{}24m 4m{a24m 4mga}24m 4m{}24m 4ma0m

       Extract the list words from a string that is not a well-formed list:
              1msplit 22m"Example with {unbalanced brace character"
                   4m=>24m 4mExample24m 4mwith24m 4m\{unbalanced24m 4mbrace24m 4mcharacter0m

       Split a string into its constituent characters
              1msplit 22m"Hello world" {}
                   4m=>24m 4mH24m 4me24m 4ml24m 4ml24m 4mo24m 4m{24m 4m}24m 4mw24m 4mo24m 4mr24m 4ml24m 4md0m

1mPARSING RECORD-ORIENTED FILES0m
       Parse  a  Unix  /etc/passwd file, which consists of one entry per line,
       with each line consisting of a colon-separated list of fields:
              ## Read the file
              set fid [open /etc/passwd]
              set content [read $fid]
              close $fid

              ## Split into records on newlines
              set records [1msplit 22m$content "\n"]

              ## Iterate over the records
              foreach rec $records {

                 ## Split into fields on colons
                 set fields [1msplit 22m$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"
              }


1mSEE ALSO0m
       join(n), list(n), string(n)


1mKEYWORDS0m
