There have been instances in the past where I had the need to reverse the characters I had received from the user input. To assist us in creating a reverse string, Tcl provides the reverse
keyword.
The syntax of the string command is as follows:
string reverse string
The string
command returns the value stored in string
in reverse order.
To complete the following example, we will need to access Tcl from the command line. Launch the Tcl shell appropriately for your operating system and follow the given instructions.
In the following example, we will create a string that is the reverse of the original. Return values from the commands are provided for clarity. Enter the following command:
% string reverse abc cba