比對字串是以 Unicode 逐一比對 string1 & string2.
compare: string1 內含字元大於 string2, 則回傳 1
compare: string1 內含字元相同 string2, 則回傳 0
compare: string1 內含字元小於 string2, 則回傳 -1
equal: string1 完全等於 string2, 則回傳 1, 反之回傳 0
syntax]:
- nocase | 比對時不分大小寫
- length | 決定比對的長度 "length len"
example]:
compare: string1 內含字元大於 string2, 則回傳 1
compare: string1 內含字元相同 string2, 則回傳 0
compare: string1 內含字元小於 string2, 則回傳 -1
equal: string1 完全等於 string2, 則回傳 1, 反之回傳 0
syntax]:
- string compare string1 string2
- string equal string1 string2
- nocase | 比對時不分大小寫
- length | 決定比對的長度 "length len"
example]:
set s2 "Hello Tcl !!"
set s3 "Hello tcl !!"
puts [string compare $s2 $s3]
puts [string compare -nocase $s2 $s3]
puts [string equal $s2 $s3]
puts [string equal -nocase $s2 $s3]
set s3 "Hello tcl !!"
puts [string compare $s2 $s3]
puts [string compare -nocase $s2 $s3]
puts [string equal $s2 $s3]
puts [string equal -nocase $s2 $s3]
沒有留言:
張貼留言