- append: 字串串接
- length: 取字串長度
- bytelength: 取自串的位元數
- index: 擷取單一字元
- range: 擷取字串中的一段字
- tolower: 將字串裡的英文由大寫轉換為小寫
- toupper: 將字串裡的英文由小寫寫轉換為大寫
- totitle: 將字串裡的第一個字母轉為大寫, 其他轉為小寫
- map: 字串取代
- trim: 剔除空白字元
- repeat: 字串重製
- split: 字串轉清單
syntax]: append varName string1 string2 .... stringN
example]:
set s1 "Hi!Everyone"
append s1 "... Good morning."
put $s1
output]:
Hi!Everyone... Good morning.
- INDEX
syntax]: string index string1 charIndex
example]:
set s1 "Hi!Everyone"
puts [string index $s1 3]
puts [string index $s1 end-1]
output]:
E # --> 取第四個字 (0=H, 1=i, 2=!, 3=E)
n # --> 取倒數第二個字 (end-0=e, end-1=n)
- RANGE
syntax]: string range string1 first last
example]:
set s1 "Hi!Everyone"
puts [string range $s1 3 7]
puts [string range $s1 3 end-1]
output]:
Every # --> output string range from 3 to 7.
Everyon # --> output string range from 3 to 倒數第二個字串
Every # --> output string range from 3 to 7.
Everyon # --> output string range from 3 to 倒數第二個字串
- TOLOWER, TOUPPER, TOTITLE
syntax]: string tolower/toupper/totitle string1
example]:
set s1 "Hi!Everyone"
puts [string tolower $s1]
puts [string toupper $s1]
puts [string totitle $s1]
syntax]: string tolower/toupper/totitle string1
example]:
set s1 "Hi!Everyone"
puts [string tolower $s1]
puts [string toupper $s1]
puts [string totitle $s1]
output]:
hi!everyone
HI!EVERYONE
Hi!everyone
hi!everyone
HI!EVERYONE
Hi!everyone
沒有留言:
張貼留言