String.indexOf(substring [,start])
Previous  Top  Next

Syntax
myString.indexOf(substring, [startIndex])

Arguments
substring: An integer or string specifying the substring to be searched for within myString.
startIndex: An integer specifying the starting point in myString to search for substring. This parameter is optional.

Returns

Returns the index of the first occurance of the specified substring.

Description
Method: Searches the string and returns the position of the first occurrence of the specified substring. If the value is not found, the method returns -1.

Sample
onLoad () {

str = "abcdefgbc";
trace (str.indexof("bc"));   // returns 1, position of "bc"
trace (str.indexof("bd"));   // returns -1, not found
trace (str.indexof("bc",3));   // returns 7, second occurance
trace (str.indexof("cd",4));   // returns -1 as "cd" exists before index 4
trace (str);
}