描述 从原字串中撷取一段字串。你可以指定一个开始位置 (撷取的字串会包含开始位置的字元) 以及结束位置 (撷取的字串不会包含结束位置的字元。假如没有输入结束位置,预设会撷取至字串结尾之前。 语法 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 […]
描述 测试字串是否以指定的字元 (或字串) 做为开头。 语法 string.startsWith(string2) 参数 string : String 物件 (字串) string2 : 另一个 String 物件 (字串) 回传 true: 假如 string 是以 string2 为开头 false: 与上面相反 范例 - StringStartsWithEndsWith See also - String - endsWith() Language Reference Home The text of the 86Duino reference is a modification of the Arduino reference, and is licensed […]
描述 把字串中指定位置的字元设定成另一个字元。这不会影响字串的长度。 语法 string.setCharAt(index, c) 参数 string : String 物件 (字串) index : 指定的字元位置 c : 另一个字元 回传 无回传值 See also - String - charAt() 语法参考主页面 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 […]
描述 String 物件的 reserve() 函式可以配置一块记忆体空间来存放字串。 语法 string.reserve(size) 参数 string : String 物件 (字串) size : 要配置的记忆体大小 (用来存放字串) unsigned int 型别 回传 无回传值 范例 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 […]
描述 String 物件的 replace() 函式可以用另一个字元替代原字串中的字元。另外,你也可以用另一个字串来替代原字串中的字串。 语法 string.replace(substring1, substring2) 参数 string : String 物件 (字串) substring1 : 另一个 String 物件 (字串) substring2 : 另一个 String 物件 (字串) 回传 替换后的字串 范例 - StringReplace See also - String 语法参考主页面 The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative […]
描述 取得字串长度 (以字元为单位)。(注意:没有包括最后的结尾字符 \0) 语法 string.length() 参数 string : String 物件 (字串) 回传 字串长度 以字元为单位 范例 - StringLengthTrim 语法参考主页面 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.
描述 在原字串中寻找字元或另一个字串。预设是从原字串结尾往开头方向寻找,或者你也可以从指定的起始位置开始寻找。 语法 string.lastIndexOf(val) string.lastIndexOf(val, from) 参数 string : String 物件 (字串) val : 要寻找的值 字元或字串 from : 指定一个起始位置 回传 要找的值在原字串的位置。如果没找到则回传 -1。 范例 - StringIndexOf See also - String - indexOf() - startsWith() - endsWith() Language Reference Home The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under […]
描述 在原字串中寻找字元或另一个字串。预设是从原字串开头开始寻找,或者你也可以从指定的起始位置开始寻找。 语法 string.indexOf(val) string.indexOf(val, from) 参数 string : String 物件 (字串) val : 要寻找的值 字元或字串 from : 指定一个起始位置 回传 在原字串中,指定值所在的位置。如果没找到则回传 -1。 范例 - StringIndexOf See also - String - lastIndexOf() - startsWith() - endsWith() 语法参考主页面 The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative […]
描述 将字串转换成 byte 阵列。 语法 string.getBytes(buf, len) 参数 string : String 物件 (字串) buf : 指定的阵列 (byte [] 型别) len : 阵列的长度 (unsigned int 型别) 回传 无回传值 See also - String - toCharArray() 语法参考主页面 The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike […]
描述 比较两个字串是否相等。比较过程中不会区分大小写,所以字串 hello 和字串 HELLO 是相同的。 语法 string.equalsIgnoreCase(string2) 参数 string : String 物件 (字串) string2 : 另一个 String 物件 (字串) 回传 true: 假如 string 字串与 string2 字串相同 false: 与上面相反 范例 - StringComparisonOperators See also - String - equals() - compareTo() 语法参考主页面 The text of the 86Duino reference is a modification of the Arduino reference, and […]