substring()
描述
从原字串中撷取一段字串。你可以指定一个开始位置 (撷取的字串会包含开始位置的字元) 以及结束位置 (撷取的字串不会包含结束位置的字元。假如没有输入结束位置,预设会撷取至字串结尾之前。
语法
string.substring(from)
string.substring(from, to)
参数
string
: String 物件 (字串)
from
: 字串撷取的开始位置 (包含开始位置的字元)
to
(非必要的): 字串撷取的结束位置 (不包含结束位置的字元)
回传
撷取后的字串
范例
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.