
String.lastIndexOf() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
810
|
ActionScript Language Reference
// Increment score if guess contains "einstein"
if (search(guess, answer)) {
score++;
}
See Also
String.charAt(), String.lastIndexOf(), String.toLowerCase(); “The indexOf() function,” in
Chapter 4
String.lastIndexOf() Method
find the last occurrence of a substring in a string
Flash 5
string.lastIndexOf(substring)
string.lastIndexOf(substring, startIndex)
Arguments
substring A string containing the character or characters for which to search.
startIndex An optional integer position in
string at which to start the search for
substring. The string is searched backward from startIndex, which should
be in the range of 0 (the first character) to
string.length – 1 (the last char-
acter). Defaults to
string.length – 1.
Returns
The position of the last occurrence of substring in string prior to startIndex. Returns –1 if
substring is not found prior to startIndex in string.
Description
The lastIndexOf() method is used to search for the last occurrence of a substring in a string
or to check whether a string contains a certain substring. The search is case-sensitive. Use
toLowerCase() to ensure a case-neutral search, as shown in the Example under String.
indexOf().
Example
URL = "http://www.moock.org/webdesign/flash/fillthewindow.html";
// Finds the ...