"indexOf" (string::indexOf)
Returns the index position of the first occurrence of the string s in this string.
Synopsis
int string.indexOf(string s, int from = 0, CaseSensitivity cs =
CaseSensitive);
Parameters
| Parameter | Description |
|---|---|
| s | String to be searched. |
| from | Start index for the search. |
| cs |
Decides if the search is case sensitive. Can be either:
|
Description
Returns the index position of the first occurrence of the string s in this string, searching forward from index position from.
Returns -1 if s is not found.
If from is -1, the search starts at the last character; if it is -2, at the next to last character and so on.
Example
main()
{
string s = "Sensor sensor SENSOR";
DebugN(s.indexOf("sensor", 0, string::CaseSensitive));
DebugN(s.indexOf("sensor", 8, string::CaseInsensitive));
}
Console output:
WCCOAui1:["7"]
WCCOAui1:["14"]
Assignment
String
