string firststring1string2——返回string1开始第一个匹配 的字符的索引,string2如果没有匹配,则返回 -1 string laststring1string2——返回string1开始最后一个匹配的字符的索引,string2如果没有匹配,则返回 -1 string wordendstringindex——返回包含index'th 个字符的单词中最后一个字符之后的字符索引string。单...
string equal ?-nocase?str1 str2 比较字符串,相同返回 1,否则返回 0。 string firststr1 str2 返回在 str2 中 str1 第一次出现的索引位置,如果没有找到则返回-1 string indexstr index 返回指定位置的字符。index 号从 0 开始。如果 index 为 end 则返回最后一个字符。 string isclass?-strict? ?-fa...
puts [string last $s2 $s1] puts "Word end index in s1" puts [string wordend $s1 20] puts "Word start index in s1" puts [string wordstart $s1 20] 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 编译并执行上述代码后,将产生以下输出- First occurrence of o in s1 4...
string first string1 string2 ?startindex? #在string2 中从头查找与string1匹配的字符序列,如果找到,那么就返回匹配的第一个字母所在的位置(0-based)。如果没有找到,那么返回-1。如果给出了startindex变量,那么将从startindex处开始查找 >> string first ab defabc 3; >> 3 >> string first ab defabc 4...
string equal "This is a TCLTK example" "This is a tcltk example";#不同返回0 string equal "This is a tcltk example" "This is a tcltk example";#相同返回1 搜索字符串 string first "tcltk" "This is a tcltk example";#返回10,返回第一次匹配的索引,如果找不到则返回-1 ...
10、 $string1 $string2 串1等于串2返回1,不相等返回0介绍字符串操作介绍字符串操作3 3、string tolower string tolower stringstring ? ?firstfirst? ? ?lastlast? ? 返回值为:把字符串string转换成小写后的字符串,如 果给出了first和last变量,就只转换first和last之间的字符 例如:string tolower TW-GONGJ...
(6)、string range string first last 与string index string charIndex类似,只不过他需要两个索引,返回的是first到last之间的字符串,如果fisrst小于0按0处理,last类似。 此外当字符串中含有空格等符号时需要使用””弱引用。 example: (7)、string replace string first last ?newstring?
常用变量类型:string list array directionary collection(snopsys) 变量存储类型分为字符串表达形式和内部表达形式(整数、实数、名称、列表、tcl脚本) string变量: 命令语法:string option arg arg string match -nocase Pattern string 如果pattern匹配string,返回1,否则返回0;如果有-nocase参数,表示不区分大小写; ...
tcl> stringtrimright"xxabcxxxx" xxxabc tcl> stringtrimleft" a bc" a bc Here comes a small example that finds the word with 'x' in a sentence. tcl> set s {abc dexfgh ijklm} tcl> string first x $s 6 tcl> set start [stringwordstart$s 6] ;# start position ...
string命令: 命令格式:string option string1 string2 option 是 操作选项,有如下可选: compare : 按照字母的排序方式比较,string1 <,=,>string2,分别返回-1,0,1 match : 判断string1和string2是否匹配 first : 检索string2中第一次出现string1的位置,如果没有出现string1则返回-1 ...