Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 299

Programming actionscript 3.0
Table of Contents

Advertisement

Flags and properties
The following table lists the five flags that you can set for regular expressions. Each flag can be
accessed as a property of the regular expression object.
Flag
Property
g
global
i
ignoreCase
m
multiline
s
dotall
x
extended
Note that these properties are read-only. You can set the flags (
regular expression variable, as follows:
var re:RegExp = /abc/gimsx;
However, you cannot directly set the named properties. For instance, the following code
results in an error:
var re:RegExp = /abc/;
re.global = true; // This generates an error.
By default, unless you specify them in the regular expression declaration, the flags are not set,
and the corresponding properties are also set to
Additionally, there are two other properties of a regular expression:
The
property specifies the index position in the string to use for the next call
lastIndex
to the
or
exec()
The
property specifies the string that defines the pattern portion of the regular
source
expression.
The g (global) flag
When the
(
g
global
match. For example, with the
method returns only one matching substring:
String.match()
var str:String = "she sells seashells by the seashore.";
var pattern:RegExp = /sh\w*/;
trace(str.match(pattern)) // output: she
Description
Matches more than one match.
Case-insensitive matching. Applies to the
but not to extended characters such as
With this flag set,
of a line, respectively.
With this flag set,
Allows extended regular expressions. You can type spaces in the
regular expression, which are ignored as part of the pattern. This lets
you type regular expression code more legibly.
method of a regular expression.
test()
) flag is not included, a regular expression matches no more than one
flag not included in the regular expression, the
g
and
can match the beginning of a line and end
$
^
(dot) can match the newline character (
.
g
.
false
and
characters,
A
Z
a
z
and
.
É
é
\n
,
,
,
,
) when you set a
i
m
s
x
Regular expression syntax
).
299

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents