Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
String Object
String.charAt
String.indexOf
METHOD: String::lastIndexOf
object.
lastIndexOf
(searchValue,[fromIndex])
When called from a
String
object, this method returns the index of the last occurrence of the specified
searchValue
argument, searchng backwards from the specified
fromIndex
argument. If the searchValue is not found, a value of -1 is returned. Characters in the string are indexed from left to right with the first character indexed as
0
and the last as
String.length-1
. Note that this method is case sensitive as shown in the example below.
The following code uses the
lastIndexOf
method to find the index values of four different character strings within the
myString
object. Note that the third example returns
-1
because there is no occurrence of the specified string before index value
6
, and the fourth example returns
-1
because the case of one of the characters does not match.
Code:
myString = new String("DevGuru.com")
document.writeln(myString.lastIndexOf("u"))
document.writeln("<br>" + myString.lastIndexOf("u",5))
document.writeln("<br>" + myString.lastIndexOf("com",6))
document.writeln("<br>" + myString.lastIndexOf("Com"))
Output:
6
4
-1
-1
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information