Lastindexof (String.lastindexof Method) - MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

lastIndexOf (String.lastIndexOf method)

public lastIndexOf(value:String, [startIndex:Number]) : Number
Searches the string from right to left and returns the index of the last occurrence of
value
found before
within the calling string. This index is zero-based, meaning that the
startIndex
first character in a string is considered to be at index 0--not index 1. If
is not found, the
value
method returns -1.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
- The string for which to search.
value:String
[optional] - An integer specifying the starting point from which to
startIndex:Number
search for
.
value
Returns
- The position of the last occurrence of the specified substring or -1.
Number
Example
The following example shows how to use
to return the index of a certain
lastIndexOf()
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
indexOf (String.indexOf method)
632
ActionScript classes

Advertisement

Table of Contents
loading

Table of Contents