VBScript的字串方法

來源:互聯網
上載者:User
方法 描述 傳參樣本 結果
Asc(string) 返回第一個字元的ASCII碼,相當於JS的String.charCodeAt "Alpha" 65
Chr(charcode) 返回對應的字母,相當於JS的String.fromCharCode 65 A
CStr(expression) 把運算式轉換為字串類型 5+5 10
InStr([start,]string,substring) 可返回substring在string中首次出現的位置。相當於JS的indexOf "Two words","w"
3,"Two words","w"
2
5
InStrRev(string,substring[,start]) 返回substring在string中首次出現的位置。搜尋從字串的末端開始,但是返回的位置是從字串的起點開始計數的,相當於JS的lastIndexOf。 "1234567890123","3"
"1234567890123","3",5
13
3
Join(stringarray[,delimter]) 將一個字串數群組轉換為數組,delimter為分隔字元,預設是空白字元,相當於JS中的數組方法join. Array("one","two","three")
Array("one","two","three"),"*"
one two three
one*two*three
LCase(string) 把指定的字串轉換為小寫。相當於JS的toLowerCase "LOWERCASE" lowercase
Left(string,number) 從字串的左側返回指定數目的字元,有點像JS的substr方法 "Left Nine Characters.",9 Left Nine
Len(string) 返回字串的長度 "This string is 34 characters long." 34
LTrim(string) 除去字串開始的空格,就是firefox的trimLeft方法 "     No leading spaces." No leading spaces.
Mid(string,start[,length]) 從字串中返回指定數目的字元,用法與JS的slice差不多 "This is the middle of the string.",13
"This is the middle of the string.",13,6
middle of the string.
middle
Replace(string,a,b) 將字串string中的a子串全部替換為b子串,與JS的replace方法差不多 "These characters are the Right Ten.",10 Right Ten.
RTrim(string) 去掉右邊的空白,就是firefox的trimRight方法 "No trailing spaces.     " No trailing spaces.
Space(number) 返回由指定數目的空格組成的字串 10  
Split(string[,delimter]) 用分隔字元切割實際字串為數組,預設是一個格的空白字元. "How now brown cow?"
"How now, brown cow?",","
Array("How","now","brown","cow?")
Array("How now"," brown cow?")
StrComp(string1,string2) 比較兩個字串,並返回表示比較結果的一個值,返回1,0,-1,1表示大於 "beta","alpha"
"alpha","alpha"
"alpha","beta"
1
0
-1
StrReverse(string) 反轉一個字串 ".redro esrever ni gnirts tupni eht si sihT" This is the input string in reverse order.
String(number,charcode) 返回包含指定長度的重複字元的一個字串 10,65 AAAAAAAAAA
Trim(string) 去掉兩端的空白,就是JS的trim方法 "     No leading or trailing spaces.     " No leading or trailing spaces.
UCase(string) 將所有字母大寫化,相當於JS的toUpperCase. "uppercase" UPPERCASE

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.