Siebel eScript Language Reference > Siebel eScript Commands > String Objects >

indexOf() Method


This method returns the position of the first occurrence of a substring in a string.

stringVar.indexOf(substring [, offset])

Parameter
Description
substring
One or more characters to search for
offset
The position in the string at which to start searching, where 0 represents the first character

Returns

The position of the first occurrence of a substring in a string variable.

Usage

stringVar.indexOf() searches the entire substring in a string variable. The substring parameter may be a single character. If offset is not given, searching starts at position 0. If it is given, searching starts at the specified position.

For example,

var string = "what a string";
string.indexOf("a")

returns the position of the first a appearing in the string, which in this example is 2. Similarly,

var magicWord = "abracadabra";
var secondA = magicWord.indexOf("a", 1);

returns 3, the index of the first a to be found in the string when starting from the second character of the string.

NOTE:  The indexOf() method is case-sensitive.

See Also

Clib.strchr() Method, Clib.strpbrk() Method, charAt() Method, lastIndexOf() Method, and string.replace() Method


 Siebel eScript Language Reference 
 Published: 18 April 2003