User Guide

304 Using Regular Expressions
trace(result.index, "\t", pattern.lastIndex, "\t", result);
result = pattern.exec(str);
}
//output:
// 0 3 She
// 10 19 seashells
// 27 35 seashore
String methods that use RegExp parameters
The following methods of the String class take regular expressions as parameters: match(),
replace(), search(), and split(). For more information on these methods, see “Finding
patterns in strings and replacing substrings” on page 216.
Example: A Wiki parser
This simple Wiki text conversion example illustrates a number of uses for regular expressions:
Converting lines of text that match a source Wiki pattern to the appropriate HTML
output strings.
Using a regular expression to convert URL patterns to HTML <a> hyperlink tags.
Using a regular expression to convert U.S. dollar strings (such as "$9.95") to euro strings
(such as
"8.24 €").
The WikiEditor application files can be found in the folder Samples/WikiEditor. The
application consists of the following files:
File Description
WikiEditor.mxml The main application file in MXML for Flex.
com/example/programmingas3/
regExpExamples/WikiParser.as
A class that includes methods that use regular
expressions to convert Wiki input text patterns
to the equivalent HTML output.
com/example/programmingas3/
regExpExamples/URLParser.as
A class that includes methods that use regular
expressions to convert URL strings to HTML
<a> hyperlink tags.
com/example/programmingas3/
regExpExamples/CurrencyConverter.as
A class that includes methods that use regular
expressions to convert U.S. dollar strings to
euro strings.