textu...:split(n)
π textutil::split β the split-y bestie of Tcl π
okay so. bestie. you have a string. you need it in PIECES. that's literally it. that's the whole vibe of textutil::split, a package from the textutil family, and it's giving "tiny utility, enormous main character energy" π
πΈ NAME πΈ
textutil::split β procedures to split texts β¨
π¦ SYNOPSIS π¦
package require Tcl 8.5 9
package require textutil::split ?0.9?
::textutil::split::splitn string ?len?
::textutil::split::splitx string ?regexp?
π DESCRIPTION π
The package textutil::split provides commands that split strings by size and arbitrary regular expressions. no cap, that's the entire job description π
The complete set of procedures is described below. there are two. two little icons. we love them π«Ά
π ::textutil::split::splitn string ?len?
This command splits the given string into chunks of len characters and returns a list containing these chunks.
- The argument
lendefaults to1if none is specified. yes queen, one char at a time if you don't say otherwise π - A negative length is not allowed and will cause the command to throw an error. so don't. π
- Providing an empty string as input is allowed, the command will then return an empty list. π
- If the length of the string is not an entire multiple of the chunk length, then the last chunk in the generated list will be shorter than
len. it's a little guy. it's doing its best. π
π ::textutil::split::splitx string ?regexp?
This command splits the string and return a list. β¨ The string is split according to the regular expression regexp instead of a simple list of chars.
β οΈ Note: when parentheses are used in the regexp, i.e. regex capture groups, then these groups will be added into the result list as additional elements. they're not gone, they're extra. periodt.
- If the string is empty the result is the empty list, like for
split. - If
regexpis empty the string is split at every character, likesplitdoes. - The regular expression
regexpdefaults to"[\\t \\r\\n]+". π
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems. (their words!! not mine!! but like. honestly. fair. πΈ)
Please report such in the category textutil of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation. we want your thoughts bestie, all of them π
When proposing code changes, please provide unified diffs, i.e the output of diff -u. π§
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. yep, that one. the left-most one. you got this π
π SEE ALSO π
β KEYWORDS β
- regular expression
- split
- string
π CATEGORY π
Text processing
and that's the whole page, bestie!! this manual page for textu...:split(n) ships with tcllib, version 0.9 β go forth and split responsibly π
β¨π¦
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms