Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 306

Programming actionscript 3.0
Table of Contents

Advertisement

The parentheses in the regular expression define a capturing group, and the
method refers to this group by using the
flag in the regular expression ensures that the
string (not simply the first one).
The
parseItalic()
checks for two apostrophes (
private function parseItalic(input:String):String
{
var pattern:RegExp = /''(.*?)''/g;
return input.replace(pattern, "<i>$1</i>");
}
Converting bullet patterns
As the following example shows, the
pattern (such as
* foo
private function parseBullets(input:String):String
{
var pattern:RegExp = /^\*(.*)/gm;
return input.replace(pattern, "<li>$1</li>");
}
The
symbol at the beginning of the regular expression matches the beginning of a line. The
^
(
) flag in the regular expression causes the regular expression to match the
m
multiline
symbol against the start of a line, not simply the start of the string.
The
pattern matches an asterisk character (the backslash is used to signal a literal asterisk
\*
instead of a
quantifier).
*
The parentheses in the regular expression define a capturing group, and the
method refers to this group by using the
flag in the regular expression ensures that the
string (not simply the first one).
Converting paragraph Wiki patterns
The
linesToParagraphs()
paragraph tag. These lines in the method strip out empty lines from the input Wiki
<p>
string:
var pattern:RegExp = /^$/gm;
var result:String = input.replace(pattern, "");
306
Using Regular Expressions
$1
method works similarly to the
) as the delimiter for italic text (not three):
''
parseBullet()
) and transforms it into its HTML equivalent (such as
$1
method converts each line in the input Wiki string to an HTML
code in the replacement string. The
method replaces all matches in the
replace()
parseBold()
method looks for the Wiki bullet line
code in the replacement string. The
method replaces all matches in the
replace()
replace()
(
g
global
method, except that it
<li>foo</li>
^
replace()
(
g
global
)
):
)

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents