这里对string命令中的几个子命令使用实例进行一些解释,以便于更加容易理解string命令中的各个子命令,本文仅对以下几个string命令进行实例解析。分别是repeat、replace、reverse、tolower、totitle、toupper、trim、trimleft、trimright、wordend和wordstart几个子命令。
string repeat
string count
非常简单,返回一个把string重复count次的字符串。
% string repeat "This" 3
ThisThisThis
ThisThisThis
string replace
string first last ?
newstring?
也很简单,使用newstring替换string中的first到last的字符串,如果没有newstring,就是使用空代替。
% string replace "This is a tcltk example" 10 14 TCLTK
This is a TCLTK example
This is a TCLTK example
如果没有newstring:
% string repla