thor
thor

Reputation: 2284

How to strip whitespace in string in TCL?

I need to strip leading and trailing whitespace from a string in TCL. How?

Upvotes: 7

Views: 28098

Answers (2)

try this. this will remove all the withe spaces

[string map {" " ""} $a];

a is your string

Upvotes: 0

Sachin Shanbhag
Sachin Shanbhag

Reputation: 55489

Try this -

      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).

Original Source :- http://wiki.tcl.tk/10174

Upvotes: 15

Related Questions