Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 301

Programming actionscript 3.0
Table of Contents

Advertisement

Note that only the
\n
Return (
) character
\r
Unicode line-separator (
Unicode paragraph-separator (
The s (dotall) flag
If the
(
or "dot all") flag is not set, a dot (
s
dotall
match a newline character (
var str:String = "<p>Test\n";
str += "Multiline</p>";
var re:RegExp = /<p>.*?<\/p>/;
trace(str.match(re));
However, if the
flag is set, the dot matches the newline character:
s
var str:String = "<p>Test\n";
str += "Multiline</p>";
var re:RegExp = /<p>.*?<\/p>/s;
trace(str.match(re));
In this case, the match is the entire substring within the
character:
<p>Test
Multiline</p>
The x (extended) flag
Regular expressions can be difficult to read, especially when they include a lot of metasymbols
and metasequences. For example:
/<p(>|(\s*[^>]*>)).*?<\/p>/gi
When you use the
(
x
the pattern are ignored. For example, the following regular expression is identical to the
previous example:
/
<p
(>
| (\s* [^>]* >))
If you have the
flag set and do want to match a blank space character, precede the blank
x
space with a backslash. For example, the following two regular expressions are equivalent:
/foo bar/
/foo \ bar/x
character signals the end of a line. The following characters do not:
) character
\u2028
) character
\u2029
). So for the following example, there is no match:
\n
) flag in a regular expression, any blank spaces that you type in
extended
) in a regular expression pattern does not
.
tags, including the newline
<p>
.*?
<\/p>
/gix
Regular expression syntax
301

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents