{"id":6205,"date":"2022-12-20T18:58:01","date_gmt":"2022-12-20T21:58:01","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/split-mann\/"},"modified":"2022-12-20T18:58:01","modified_gmt":"2022-12-20T21:58:01","slug":"split-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/split-mann\/","title":{"rendered":"split (mann)"},"content":{"rendered":"<h1 align=\"center\">split<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">split \u2212 Split a string into a proper Tcl list<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>split<\/b> <i>string<\/i> ?<i>splitChars<\/i>? ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns a list created by splitting <i>string<\/i> at each character that is in the <i>splitChars<\/i> argument. Each element of the result list will consist of the characters from <i>string<\/i> that lie between instances of the characters in <i>splitChars<\/i>. Empty list elements will be generated if <i>string<\/i> contains adjacent characters in <i>splitChars<\/i>, or if the first or last character of <i>string<\/i> is in <i>splitChars<\/i>. If <i>splitChars<\/i> is an empty string then each character of <i>string<\/i> becomes a separate element of the result list. <i>SplitChars<\/i> defaults to the standard white-space characters.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Divide up a USENET group name into its hierarchical components:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>split<\/b> &#8220;comp.lang.tcl&#8221; . <i><br \/> \u2192 comp lang tcl<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">See how the <b>split<\/b> command splits on <i>every<\/i> character in <i>splitChars<\/i>, which can result in information loss if you are not careful:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>split<\/b> &#8220;alpha beta gamma&#8221; &#8220;temp&#8221; <i><br \/> \u2192 al {ha b} {} {a ga} {} a<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Extract the list words from a string that is not a well-formed list:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>split<\/b> &#8220;Example with {unbalanced brace character&#8221; <i><br \/> \u2192 Example with {unbalanced brace character<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Split a string into its constituent characters<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>split<\/b> &#8220;Hello world&#8221; {} <i><br \/> \u2192 H e l l o { } w o r l d<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>PARSING RECORD-ORIENTED FILES<\/b> <br \/> Parse a Unix \/etc\/passwd file, which consists of one entry per line, with each line consisting of a colon-separated list of fields:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">## Read the file <br \/> set fid [open \/etc\/passwd] <br \/> set content [read $fid] <br \/> close $fid<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">## Split into records on newlines <br \/> set records [<b>split<\/b> $content &#8220;n&#8221;]<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">## Iterate over the records <br \/> foreach rec $records {<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">## Split into fields on colons <br \/> set fields [<b>split<\/b> $rec &#8220;:&#8221;]<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">## Assign fields to variables and print some out&#8230; <br \/> lassign $fields  <br \/> userName password uid grp longName homeDir shell <br \/> puts &#8220;$longName uses [file tail $shell] for a login shell&#8221; <br \/> }<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">join(n), list(n), string(n)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">list, split, string<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  split \u2212 Split a string into a proper Tcl list <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3783,1],"tags":[2635,2510],"class_list":["post-6205","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-mann","tag-split"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6205"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6205\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}