Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 302

Programming actionscript 3.0
Table of Contents

Advertisement

The lastIndex property
The
property specifies the index position in the string at which to start the next
lastIndex
search. This property affects the
that has the
flag set to
g
var pattern:RegExp = /p\w*/gi;
var str:String = "Pedro Piper picked a peck of pickled peppers.";
trace(pattern.lastIndex);
var result:Object = pattern.exec(str);
while (result != null)
{
trace(pattern.lastIndex);
result = pattern.exec(str);
}
The
property is set to 0 by default (to start searches at the beginning of the string).
lastIndex
After each match, it is set to the index position following the match. Therefore, the output for
the preceding code is the following:
0
5
11
18
25
36
44
If the
flag is set to
global
property.
lastIndex
The
,
match()
replace()
the beginning of the string, regardless of the setting of the
expression used in the call to the method. (However, the
to 0.)
lastIndex
You can set the
lastIndex
expression matching.
The source property
The
property specifies the string that defines the pattern portion of a regular
source
expression. For example:
var pattern:RegExp = /foo/gi;
trace(pattern.source); // foo
302
Using Regular Expressions
and
exec()
test()
. For example, consider the following code:
true
, the
false
exec()
, and
methods of the String class start all searches from
search()
property to adjust the starting position in the string for regular
methods called on a regular expression
and
methods do not use or set the
test()
lastIndex
method does set
match()
property of the regular

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents