描述 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 […]
描述 比较两个字串是否相等。比较过程中会区分大小写,所以字串 hello 和字串 HELLO 是不同的。 语法 string.equals(string2) 参数 string : String 物件 (字串) string2 : 另一个 String 物件 (字串) 回传 true: 假如 string 字串与 string2 字串相同 false: 与上面相反 范例 - StringComparisonOperators See also - String - equalsIgnoreCase() - compareTo() 语法参考主页面 The text of the 86Duino reference is a modification of the Arduino reference, and […]
描述 测试一个字串结尾和另一个字串结尾是否相同。 语法 string.endsWith(string2) 参数 string: String 物件 (字串) string2: 另一个 String 物件 (字串) 回传 true: 假如 string 字串的结尾与 string2 字串的结尾相同 false: 与上面相反 范例 - StringStartsWithEndsWith See also - String - startsWith() 语法参考主页面 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.concat(string2) 参数 string, string2: String 物件 (字串) 范例 - StringAppendOperator See also - String - String Addition operator 语法参考主页面 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 […]
描述 比较两个字串,看看两者之中谁在前面、后面或相同。过程中会取两字串的每个字元做 ASCII 值比较,举例来说,’a’ 会在 b 前面和 A 后面。另外,数字总是在字母前面。 语法 string.compareTo(string2) 参数 string: String 物件 (字串) string2: 另一个 String 物件 (字串) 回传 负值:假如 string 是在 string2 之前 0:假如 string 等于 string2 正值:假如 string 是在 string2 之后 范例 - StringComparisonOperators See also - String - equals() - equalsIgnoreCase() - == (comparison) 语法参考主页面 The text of the […]