indexOf Method

Top  Previous  Next

Returns the position of the first occurrence of a specified value in a string.

Syntax

String.indexOf(string,number)

Arguments

stringThe string to search for.
numberA number indicating at which position to start the search.

Return Value

The position where the specified search value occurs for the first time. If the search value never occurs, it returns -1..

Examples

var String="Hello developers, welcome to CellScript!";

var n=String.indexOf("CellScript");

Net.write(n);                                      // Returns 29