13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Using regular expressions<br />

Metasequ<strong>en</strong>ce Description<br />

\r Matches the return character.<br />

\s Matches any white-space character (a space, tab, newline, or return character).<br />

\S Matches any character other than a white-space character.<br />

\t Matches the tab character.<br />

\unnnn Matches the Unicode character with the character code specified by the hexadecimal number nnnn. For<br />

example, \u263a is the smiley character.<br />

\v Matches a vertical feed character.<br />

\w Matches a word character (AZ–, az–, 0-9, or _). Note that \w does not match non-English characters, such<br />

as é , ñ , or ç .<br />

\W Matches any character other than a word character.<br />

\\xnn Matches the character with the specified ASCII value, as defined by the hexadecimal number nn.<br />

Character classes<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

You use character classes to specify a list of characters to match one position in the regular expression. You define<br />

character classes with square brackets ( [ and ] ). For example, the following regular expression defines a character<br />

class that matches bag, beg, big, bog, or bug:<br />

/b[aeiou]g/<br />

Escape sequ<strong>en</strong>ces in character classes<br />

Most metacharacters and metasequ<strong>en</strong>ces that normally have special meanings in a regular expression do not have<br />

those same meanings inside a character class. For example, in a regular expression, the asterisk is used for repetition,<br />

but this is not the case wh<strong>en</strong> the asterisk appears in a character class. The following character class matches the asterisk<br />

literally, along with any of the other characters listed:<br />

/[abc*123]/<br />

However, the three characters listed in the following table do function as metacharacters, with special meaning, in<br />

character classes:<br />

Metacharacter Meaning in character classes<br />

] Defines the <strong>en</strong>d of the character class.<br />

- Defines a range of characters (see the following section “Ranges of characters in character classes”).<br />

\ Defines metasequ<strong>en</strong>ces and undoes the special meaning of metacharacters.<br />

For any of these characters to be recognized as literal characters (without the special metacharacter meaning), you<br />

must precede the character with the backslash escape character. For example, the following regular expression includes<br />

a character class that matches any one of four symbols ($, \, ], or -):<br />

/[$\\\]\-]/<br />

In addition to the metacharacters that retain their special meanings, the following metasequ<strong>en</strong>ces function as<br />

metasequ<strong>en</strong>ces within character classes:<br />

Last updated 6/6/2012<br />

81

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!