logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

textutil::split - Procedures to split texts

Bugs, Ideas, Feedback

       This  document,  and  the package it describes, will undoubtedly contain bugs and other problems.  Please
       report such in the category  textutil  of  the  TcllibTrackers  [http://core.tcl.tk/tcllib/reportlist].
       Please also report any ideas for enhancements you may have for either package and/or documentation.

       When proposing code changes, please provide unifieddiffs, 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.

Category

       Text processing

tcllib                                                 0.9                                 textutil::split(3tcl)

Description

       The  package  textutil::split  provides  commands  that  split  strings  by  size  and  arbitrary regular
       expressions.

       The complete set of procedures is described below.

       ::textutil::split::splitnstring ?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. A negative length is not
              allowed and will cause the command to throw an error.  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.

       ::textutil::split::splitxstring ?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.  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]+".

Keywords

       regular expression, split, string

Name

       textutil::split - Procedures to split texts

See Also

regexp(3tcl), split(3tcl), string(3tcl)

Synopsis

       package require Tcl8.59

       package require textutil::split?0.9?::textutil::split::splitnstring ?len?

       ::textutil::split::splitxstring ?regexp?

________________________________________________________________________________________________________________

See Also