substring()

描述

從原字串中擷取一段字串。你可以指定一個開始位置 (擷取的字串會包含開始位置的字元) 以及結束位置 (擷取的字串不會包含結束位置的字元)。假如沒有輸入結束位置,預設會擷取至字串結尾之前。

語法


string.substring(from)
string.substring(from, to)

參數

string : String 物件 (字串)
from : 字串擷取的開始位置 (包含開始位置的字元)
to (非必要的): 字串擷取的結束位置 (不包含結束位置的字元)

回傳

擷取後的字串

範例

StringSubstring

See also

String


語法參考主頁面

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.