indexOf()

描述

在原字串中寻找字元或另一个字串。预设是从原字串开头开始寻找,或者你也可以从指定的起始位置开始寻找。

语法


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 Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.