Version 1 of string trim

Updated 2004-05-25 11:44:32 by lwv

string trim string ?chars?

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


The trimleft will remove the pathname from the beginning of the string and trimright will remove the extension. Remember that this command will not save to a variable, therefore you must set the same or another variable:

  % set foo ../returned../
  ../returned../
  % string trim $foo ./
  returned
  % set foo
  ../returned../
  % set foo [string trim $foo ./]
  returned
  % set foo
  returned

See also:


Tcl syntax help - Category Command