Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 296

Programming actionscript 3.0
Table of Contents

Advertisement

Using groups with quantifiers
If you do not use a group, a quantifier applies to the character or character class that precedes
it, as the following shows:
var pattern:RegExp = /ab*/ ;
// matches the character a followed by
// zero or more occurrences of the character b
pattern = /a\d+/;
// matches the character a followed by
// one or more digits
pattern = /a[123]{1,3}/;
// matches the character a followed by
// one to three occurrences of either 1, 2, or 3
However, you can use a group to apply a quantifier to more than one character or character
class:
var pattern:RegExp = /(ab)*/;
// matches zero or more occurrences of the character a
// followed by the character b, such as ababab
pattern = /(a\d)+/;
// matches one or more occurrences of the character a followed by
// a digit, such as a1a5a8a3
pattern = /(spam ){1,3}/;
// matches 1 to 3 occurrences of the word spam followed by a space
For more information on quantifiers, see
"Quantifiers" on page
293.
Using groups with the alternator (
) character
|
You can use groups to define the group of characters to which you want to apply an alternator
(
) character, as follows:
|
var pattern:RegExp = /cat|dog/;
// matches cat or dog
pattern = /ca(t|d)og/;
// matches catog or cadog
296
Using Regular Expressions

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents