textu...:split(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– 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 len defaults to 1 if 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 regexp is empty the string is split at every character, like split does.
  • The regular expression regexp defaults 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