tex...plit(3tcl)
β¨ NAME β¨
textutil::split β the procedures that split texts π (yes bestie, it's the textutil::split page from the 3tcl manual, aka the Text and string utilities, macro processing corner of the world π¦)
πΈ SYNOPSIS πΈ
package require Tcl 8.5 9
package require textutil::split ?0.9?
::textutil::split::splitn string ?len?
::textutil::split::splitx string ?regexp?
π DESCRIPTION π
okay so the textutil::split package hands you commands that chop up strings β by size or by whatever arbitrary regular expression your heart desires. iconic behaviour honestly π
the full set of procedures is right here, no gatekeeping:
::textutil::split::splitn string ?len?β this one takes string and slices it into chunks oflencharacters, then gives you back a list holding all those chunks. if you don't pass a len, it lowkey defaults to1. a negative length is not allowed and will make the command throw an error (do not test her π). giving an empty string as input is totally fine β you'll just get an empty list back. and if the length of the string isn't an entire multiple of the chunk length, then the last chunk in the generated list is gonna be shorter than len. not a bug, just vibes β¨::textutil::split::splitx string ?regexp?β this one splits the string and returns a list too, but it splits according to the regular expression regexp instead of a boring simple list of chars. note: when parentheses show up in the regexp β i.e. regex capture groups β those groups get added into the result list as additional elements. so yeah, extra guests at the party π«Ά. if the string is empty the result is the empty list, exactly like forsplit. if regexp is empty the string gets split at every character, likesplitdoes. the regular expression regexp defaults to"[\\t \\r\\n]+"if you don't say otherwise π
π BUGS, IDEAS, FEEDBACK π
ngl, this document β and the package it describes β will undoubtedly contain bugs and other problems. bestie please report those in the category textutil of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. also spill any ideas for enhancements you have for either the package and/or the documentation, we're listening π
when proposing code changes, please provide unified diffs, i.e the output of diff -u. periodt.
note further that attachments are strongly preferred over inlined patches π attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. it's giving very specific but very important, iykyk π
π¦ SEE ALSO π¦
β KEYWORDS β
- regular expression
- split
- string
π CATEGORY π
Text processing π
and that's the whole page, bestie! this gorgeous thing is tcllib version 0.9, living its best life under tex...plit(3tcl) π§ slay, stay split, and don't pass a negative len πβ¨π
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms