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. 0 represents the first character of the string.
Returns
Returns the index of the first occurrence of the specified substring.
Description
Method: Searches the string from right to left and returns the position of the first found (last in string) occurrence of the specified substring. If the value is not found, the method returns -1.
Sample onLoad () {
str = "abcdefgbc";
trace (str.lastindexof("bc")); // returns 7, (last position of "bc")
trace (str.lastindexof("bd")); // returns -1, not found
trace (str.lastindexof("bc",3)); // returns 7, (last position of "bc")
trace (str.lastindexof("cd",3)); // returns 2, found because 'd' of "cd" is at 3. See note below.
trace (str.lastindexof("cd",4)); // returns -1 as "cd" exists before index 4
trace (str);
}
Note: As search is from right to left, returns position before startIndex as start of string (on right to left basis) started after startIndex