Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 285

Programming actionscript 3.0
Table of Contents

Advertisement

1 0
CHAPTER 10
Using Regular Expressions
A regular expression describes a pattern that is used to find and manipulate matching text in
strings. Regular expressions resemble strings, but they can include special codes to describe
patterns and repetition. For example, the following regular expression matches a string that
starts with the character A followed by one or more sequential digits:
/A\d+/
Regular expression patterns can be complex, and sometimes cryptic in appearance, such as the
following expression to match a valid e-mail address:
/([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}/
This chapter describes the basic syntax for constructing regular expressions. However, regular
expressions can have many complexities and nuances. You can find detailed resources on
regular expressions on the web and in bookstores. Keep in mind that different programming
environments implement regular expressions in different ways. ActionScript 3.0 implements
regular expressions as defined in the ECMAScript edition 3 language specification (ECMA-
262).
You can use regular expressions with the following methods of the String class:
,
match()
, and
. For more information on these methods, see
"Finding patterns in
replace()
search()
strings and replacing substrings" on page
216.
Contents
Introduction to Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .286
Regular expression syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Methods for using regular expressions with strings . . . . . . . . . . . . . . . . . . . . . . . . . 303
Example: A Wiki parser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
285

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents