1[manpage_begin textutil::trim n 0.7]
2[see_also regexp(n)]
3[see_also split(n)]
4[see_also string(n)]
5[keywords prefix]
6[keywords {regular expression}]
7[keywords string]
8[keywords trimming]
9[moddesc   {Text and string utilities, macro processing}]
10[titledesc {Procedures to trim strings}]
11[category  {Text processing}]
12[require Tcl 8.2]
13[require textutil::trim [opt 0.7]]
14[description]
15
16The package [package textutil::trim] provides commands that trim
17strings using arbitrary regular expressions.
18
19[para]
20
21The complete set of procedures is described below.
22
23[list_begin definitions]
24
25[call [cmd ::textutil::trim::trim] [arg string] [opt [arg regexp]]]
26
27Remove in [arg string] any leading and trailing substring according to
28the regular expression [arg regexp] and return the result as a new
29string.  This is done for all [emph lines] in the string, that is any
30substring between 2 newline chars, or between the beginning of the
31string and a newline, or between a newline and the end of the string,
32or, if the string contain no newline, between the beginning and the
33end of the string.
34
35The regular expression [arg regexp] defaults to "[lb] \\t[rb]+".
36
37[call [cmd ::textutil::trim::trimleft] [arg string] [opt [arg regexp]]]
38
39Remove in [arg string] any leading substring according to the regular
40expression [arg regexp] and return the result as a new string. This
41apply on any [emph line] in the string, that is any substring between
422 newline chars, or between the beginning of the string and a newline,
43or between a newline and the end of the string, or, if the string
44contain no newline, between the beginning and the end of the string.
45
46The regular expression [arg regexp] defaults to "[lb] \\t[rb]+".
47
48[call [cmd ::textutil::trim::trimright] [arg string] [opt [arg regexp]]]
49
50Remove in [arg string] any trailing substring according to the regular
51expression [arg regexp] and return the result as a new string. This
52apply on any [emph line] in the string, that is any substring between
532 newline chars, or between the beginning of the string and a newline,
54or between a newline and the end of the string, or, if the string
55contain no newline, between the beginning and the end of the string.
56
57The regular expression [arg regexp] defaults to "[lb] \\t[rb]+".
58
59[call [cmd ::textutil::trim::trimPrefix] [arg string] [arg prefix]]
60
61Removes the [arg prefix] from the beginning of [arg string] and
62returns the result. The [arg string] is left unchanged if it doesn't
63have [arg prefix] at its beginning.
64
65[call [cmd ::textutil::trim::trimEmptyHeading] [arg string]]
66
67Looks for empty lines (including lines consisting of only whitespace)
68at the beginning of the [arg string] and removes it. The modified
69string is returned as the result of the command.
70
71[list_end]
72
73[vset CATEGORY textutil]
74[include ../common-text/feedback.inc]
75[manpage_end]
76