string index string charIndexReturns the
charIndex 'th character of the
string argument. A
charIndex of 0 corresponds to the first character of the string.
charIndex may be specified as follows:
integer- The char specified at this integral index.
end - The last char of the string.
end-integer - The last char of the string minus the specified integer offset (e.g.
end-1 would refer to the "c" in "abcd").
If
charIndex is less than 0 or greater than or equal to the length of the string then an empty string is returned.
Returns for
index an
integer, the
charIndex'th character in
string. If
index is
end, the last character in
string, and if
index is
end-integer, the last character minus the specified offset. (From the Tcl/Tk Reference Guide)
For example,
string index "abcde" "3"
returns "d" . Notice that the index is
zero based - the first character is index 0.
string index "abcde" "10"
returns "" . There is no 10th character. No error is returned here.
See also:
Tcl syntax help -
Category Command -
Category String Processing