Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 294

Programming actionscript 3.0
Table of Contents

Advertisement

You can use quantifiers within parenthetical groupings that have quantifiers applied to them.
For example, the following quantifier matches strings such as
/\w+(-\w+)*/
By default, regular expressions perform what is known as greedy matching. Any subpattern in
the regular expression (such as
before moving forward to the next part of the regular expression. For example, consider the
following regular expression and string:
var pattern:RegExp = /<p>.*<\/p>/;
str:String = "<p>Paragraph 1</p> <p>Paragraph 2</p>";
The regular expression matches the entire string:
<p>Paragraph 1</p> <p>Paragraph 2</p>
Suppose, however, that you want to match only one
with the following:
<p>Paragraph 1</p>
Add a question mark (
For example, the following regular expression, which uses the lazy
followed by the minimum number of characters possible (lazy), followed by
/<p>.*?<\/p>/
Keep in mind the following points about quantifiers:
The quantifiers
{0}
Do not combine multiple quantifiers, as in
The dot (.) does not span lines unless the
quantifier. For example, consider the following code:
var str:String = "<p>Test\n";
str += "Multiline</p>";
var re:RegExp = /<p>.*<\/p>/;
trace(str.match(re)); // null;
re = /<p>.*<\/p>/s;
trace(str.match(re));
// output: <p>Test
//
Multiline</p>
For more information, see
294
Using Regular Expressions
) tries to match as many characters in the string as possible
.*
) after any quantifier to change it to what is known as a lazy quantifier.
?
and
do not exclude an item from a match.
{0,0}
"The s (dotall) flag" on page
word
grouping. You can do this
<p>...</p>
.
/abc+*/
(
) flag is set, even if it is followed by a
s
dotall
301.
and
word-word-word
quantifier, matches
*?
:
</p>
:
<p>
*

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents