Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to strip whitespace in string in TCL?

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

like image 558
thor Avatar asked Jan 11 '11 12:01

thor


People also ask

How do I remove spaces from a string in TCL?

As its name implies, trimright is used to trim trailing whitespace or other characters as specified. The trimright keyword will return string with all trailing whitespace trimmed if no characters are provided. If the optional characters are not specified only will be removed.

How do you trim white spaces in a string?

trim() The trim() method removes whitespace from both ends of a string and returns a new string, without modifying the original string. Whitespace in this context is all the whitespace characters (space, tab, no-break space, etc.)

How do you get rid of the whitespace at the end of a string?

String result = str. trim(); The trim() method will remove both leading and trailing whitespace from a string and return the result.

How do I match a string in TCL?

The string command Use 'first' or 'last' to look for a substring. The return value is the index of the first character of the substring within the string. The 'string match' command uses the glob-style pattern matching like many UNIX shell commands do. Matches any number of any character.


1 Answers

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

like image 137
Sachin Shanbhag Avatar answered Sep 22 '22 22:09

Sachin Shanbhag