TCL使用format命令进行字符串的格式化,功能与ANSI C中的sprintf函数相似。例如:format "The square root of 10 is%.3f" [expr sqrt(10)]The square root of 10 is 3. 162format的第一个参数是格式字符串,其中可以包含任意多个像%.3f这样的转换符。针对每一个转换符,format会按照其格式替换后面表达式或参数的值。format基本上...
在TCL可以使用命令string is来判断一个字符串的类型。如果它是指定类型的字符串,就返回1,否则返回0。例如:string is digit 12341string is digit "A man, a plan acanal. Panama."0默认情况下,如果字符串为空,对任何类型string is都返回1。使用-strict选项可以强制要求在字符串为空时string is返回0。string is co...
在TCL中通过命令stringfirst和string last进行字符串的搜索,使用方法如下:string first th "There is the tubwhere I bathed today"9string first th "There is the tub where I bathed today" 1227string first在第二个字符串中搜索与第一个字符串相同的子字符串。如果找到,返回最左边的相同子字符串的开头字符的...