Name

string

string option arg...

Perform string operations on one or more strings, based on the value of option. String indices start at 0.

string compare string1 string2

Compare strings lexicographically. Return −1 if string1 is less than string2, 0 if equal, or 1 if greater.

string first string1 string2

Return the index of the first occurrence of string1 in string2, or −1 if no match.

string index string charIndex

Return the character in string that has index charIndex. Return empty string if charIndex is out of range.

string last string1 string2

Return the index of the last occurrence of string1 in string2, or −1 if no match.

string length string

Return the length of string in characters.

string match pattern string

Return 1 if string matches glob pattern pattern; otherwise, return 0.

string range string first last

Return substring of string consisting of characters from index first through last. Last can be the string “end”.

string tolower string

Return string converted to lowercase.

string toupper string

Return string converted to uppercase.

string trim string [chars]

Return string with leading and trailing characters from the set chars removed (default is whitespace characters).

string trimleft string [chars]

Return string with leading characters from the set chars removed (default is whitespace characters).

string trimright string [chars]

Return string with trailing characters from the set chars removed (default is whitespace characters).

string wordend string index

Return index of first character after ...

Get Tcl/Tk in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.