Converting a string to lowercase

To prevent the case of a string from impacting your programs, Tcl has provided several keywords to manipulate the case of stored strings. The first of these is tolower. As its name implies, the tolower keyword returns a string with all characters in lowercase.

The syntax of the string command is as follows:

	string tolower string first last

The string command will convert all upper or title characters to their lowercase values and return the newly created string. If an optional index value is passed in the first location, the conversion will commence at that location. If an index value is passed in the last location, this will designate the location at which the conversion will stop.

How to do it…

In the following example, we will create a string that contains only lowercase characters. Return values from the commands are provided for clarity. Enter the following command:


% string tolower "NOW IS THE TIME"
now is the time

How it works…

As you can see Tcl has returned our lowercase string.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.75.165