Version 14 of string trim

Updated 2015-05-17 14:24:14 by pooryorick

string trim removes characters from the beginning and end of a string.

Synopsis

string trim string ?chars?

See Also

string map
Replace substrings in a string.
Trimming indentation
textutil
Provides regular expression variants of the string trim commands, as well as trimPrefix an trimEmptyHeading.

Description

Returns a value equal to string except that any leading or trailing characters that occur in chars are removed. If chars is not specified then white space is removed (spaces, tabs, newlines, and carriage returns).

What Constitutes Whitespace

See TIP #318: Extend Default Whitespace in 'string trim' Beyond ASCII .

escargo 2008-06-02: This also related to behavior discussed in comp.lang.tcl with the subject, "string trim not trimming special space characters" (starting on 2008-03-04).

The characters removed by string trim string (with no chars argument) are not all the ones for which string is space char returns 1.

I think the TIP should also include Unicode nonbreaking spaces.

LV: You could either update the TIP page with your concerns, or post a comment over on the TCT mailing list.