String.lastIndexOf() MethodNameString.lastIndexOf() Method---search a string backwardsAvailabilityNavigator 2.0, Internet Explorer 3.0 Synopsis
string.lastIndexOf(substring) string.lastIndexOf(substring, start) Arguments
ReturnsThe position of the last occurrence of substring within string that appears before the start position, if any, or -1 if no such occurrence is found within string. DescriptionString.lastIndexOf() searches the string from end to beginning to see if it contains an occurrence of substring. The search begins at position start within string, or at the end of string if start is not specified. If an occurrence of substring is found, then String.lastIndexOf() returns the position of the first character of that occurrence. Since this method searches from end to beginning of the string, the first occurrence found will be the last one in the string that occurs before the start position. If no occurrence of substring is found, then String.lastIndexOf() returns -1. Note that although String.lastIndexOf() searches string from end to beginning, it still numbers character positions within string from the beginning. The first character of the string has position 0, and the last has position string.length-1. |
|