分类:
2008-09-09 17:45:36
|
语法: format formatstring ?vlue value...?
语法:scan string format varName ?varName...?% scan "12.34.56.78" "%d.%d.%d.%d" c d e f4% puts [format "the value of c is %d, d is %d, e is %d, f is %d" $c $d $e $f]the value of c is 12, d is 34, e is 56, f is 78
语法:regexp ?switchs? ?--? exp string ?matchVar?\ ?subMatchVar subMatchVar...?% regexp { ([0-9]+) *([a-z]+)} " there is 100 apples" total num word1% puts " $total ,$num,$word"100 apples ,100,applesswitchs:-nocase; -indices; -about; -expanded; -line; -linestop; -lineanchor; -all; -inline; -start index--表示后面再也没有开关了,即使以“-”开头
语法:regsub ?switchs? ?--? exp string subSpec varname% regsub there "They live there lives " their x1% puts $xThey live their livesswitchs:-nocase; -all; --
% string match {a[b-f]cdef} accdef1