String.lastindexof() - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

String.lastIndexOf()

Availability
Flash Player 5.
Usage
my_str.lastIndexOf(substring:String, [startIndex:Number]) : Number
Parameters
String; the string for which to search.
substring
Number; an optional integer specifying the starting point from which to search for
startIndex
.
substring
Returns
A number; the position of the last occurrence of the specified substring or -1.
Description
Method; searches the string from right to left and returns the index of the last occurrence of
found before
substring
that the first character in a string is considered to be at index 0—not index 1. If
found, the method returns -1.
Example
The following example shows how to use
character:
var searchString:String = "Lorem ipsum dolor sit amet.";
var index:Number;
index = searchString.lastIndexOf("L");
trace(index); // output: 0
index = searchString.lastIndexOf("l");
trace(index); // output: 14
index = searchString.lastIndexOf("i");
trace(index); // output: 19
index = searchString.lastIndexOf("ipsum");
trace(index); // output: 6
index = searchString.lastIndexOf("i", 18);
trace(index); // output: 6
index = searchString.lastIndexOf("z");
trace(index); // output: -1
See also
String.indexOf()
800
Chapter 2:
within the calling string. This index is zero-based, meaning
startIndex
lastIndexOf()
substring
to return the index of a certain
is not

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

This manual is also suitable for:

Flash mx

Table of Contents