substr Tcl Command


substr - parse a substring


::dmh::substr string left right


This command is used to extract the first substring in input string string that is bounded on the left by the token left and on the right by right. If either left or right is not found in the string, an empty result is returned. If the right is an empty string, everything after the left argument is returned. Also, an empty string may be used for the left argument to match the beginning of a string. For example:

set title "Notepad - substr.n"
set filename [substr $title "Notepad - " ""]
set appname [substr $title "" " -"]


Ed Hume, Hume Integration Software


string, substring