| 字串函數 |
說明 |
| length() |
傳回字串長度 |
indexOf(val)
indexOf(val, from) |
從左方搜尋子字串, 傳回首次出現位置索引 |
lastIndexOf(val)
lastIndexOf(val, from) |
從右方搜尋子字串, 傳回首次出現位置索引 |
| substring(from), substring(from, to) |
傳回子字串 |
| replace(substr1, substr2) |
將子字串 substr1 以子字串 substr2 取代 |
| concat(str) |
將 str 字串串接在後面 |
remove(index)
remove(index, count) |
刪除索引 index 到結尾之字元
刪除指定字元數 count |
| toLowerCase() |
傳回轉成小寫後之字串 |
| toUpperCase() |
傳回轉成大寫後之字串 |
| charAt(index) |
傳回指定索引之字元 |
| setCharAt(index, c) |
將字串索引 index 之字元以指定字元 c 取代 |
| equals(str) |
是否與指定字串 str 雷同, 傳回 true/false |
| equalsIgnoreCase(str) |
是否與指定字串 str 相同 (不分大小寫), 傳回 true/false |
| compareTo(str) |
與 str 字串逐字比較 ASCII 字元, 雷同傳回 0,
在後傳回正值, 在前傳回負值 |
| startsWith(str) |
是否以指定字串 str 開頭, 傳回 true/false |
| endsWith(str) |
是否以指定字串 str 結尾, 傳回 true/false |
| trim() |
清除開頭與結尾的空白字元 |
| toInt() |
將以數字開頭直到非數字字元之字串轉成長整數傳回 |
| toFloat() |
將以數字開頭直到非浮點數字元之字串轉成浮點數傳回 |
| reserve(bytes) |
要求保留指定 bytes 數之記 |