TCL脚本语言-5-简单变量和字符串处理
puts“thecharacterin10is[stringindex$a10]” 这里采用的是stringindexstringvalueindexvalue的形式,其中stringvalue是字符串, indexvalue就是字符所在下标。这里下标有三种表示方法: index语法解释和例子 integer一个从0开始的整数,首字符下标是0;如果超出字符串长度, 返回空; endend用来表示字符串的最后一个字符; end...
15 Tcl 编程初步 字符串的这些命令的使用方法比较相似.常用的字符串操作有: - string match:字符串匹配(或者比较); - 大小写转换:tolower 和 totopper 以及 totile; - equal 操作; - string compare; - string range; - string replace 等. 4.7.2 字符串比较 我们在 expr 和控制语句如 if,while 中可用...
string1string2 25 8.5.3stringfirststring1string2?startindex? 25 8.5.4stringindexstringcharIndex 26 8.5.5stringlaststring1string2?startindex? 26 8.5.6stringlengthstring 26 8.5.7stringmatch?-nocase?patternstring 26 8.5.8stringrangestringfirstlast 27 8.5.9stringrepeatstringcount 27 8.5.10stringrepla...
\k \c { x matches an empty string, without reporting a bracket expression, matching any one of the chars (see BRACKET EXPRESSIONS for more detail) matches any single character where k is a non-alphanumeric character) matches that character taken as an ordinary character, e.g. \\ matches ...
# metacharacter usage puts stdout "Hello, World! \a" puts stdout {Hello, World! \a} set Pints 6 set Days 7 puts stdout "The answer to the \ universe is [eval $Pints * $Days]!\n" *** ~/tcltk$ ./hello2.tcl Hello, World!
可以試著傳遞一個錯誤的參數給 string 指令,透過這個方式查看string指令有哪些可用的方法: % string rick bad option rick: must be bytelength, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, tolower, toupper, totitle, trim, trimleft, trimright, wordend, or...
. . . . 27 8.5.10string replace string first last ?newstring? . . . . . . . . . . . . . . . . . . . . . . . . . . 27 8.5.11string tolower string ?first? ?last? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27...
here you can do this in multiple ways 1.regsub 30 $data 40 a puts $a this will give you the replaced string 2.string replace $data 3 4 40 this also will give you the replaced value Read More 11:: Where can we find the sample tcl programs?
In this example, the command is puts, which takes two arguments: an I/O stream identifier and a string. puts writes the string to the I/O stream along with a trailing newline character. There are two points to emphasize: • Arguments are interpreted by the command. In the example, ...