Availability: |
| ||||||||
Property/method value type: | Number primitive | ||||||||
JavaScript syntax: | - | myString.lastIndexOf(aSearchString) | |||||||
- | myString.lastIndexOf(aSearchString, aPosition) | ||||||||
Argument list: | aPosition | An optional valid character position within the string to indicate the search start. Missing value or 0 indicates the entire string is to be searched | |||||||
aSearchString | A string to search for within the string object |
Locate the rightmost occurrence of the search string within the receiving String object.
If the search string cannot be found, then the value -1 is returned.
If the starting position is not indicated, the entire string will be searched.
The result of this method is the index of the rightmost occurrence of the sub-string or -1 if it is not found.
<HTML> <HEAD> </HEAD> <BODY> <SCRIPT> myString = "AAABBBCCCAAABBBCCC"; myIndex = myString.lastIndexOf("AAA"); document.write(myString.substr(myIndex)); </SCRIPT> </BODY> </HTML>
See also: | String.prototype |
Prev | Home | Next |
String.italics() | Up | String.length |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |