I’ve attempted to provide a useful reference to the most commonly used aspects of regular expressions here.  At the bottom of the page you’ll find a small Flex app for testing regular expressions in ActionScript 3.

Metacharacters:

Dot (.) is a wildcard character. So, for example /str.ng/ will match “string”, “strong” or any single character in that position except a newline. The dot always matches exactly one character.

Backslash (\) escapes a character, so if you wanted to search for a period in a string, you would need to escape it, such as /3\.14159/

Star or asterisk (*) means match the preceding item zero or more times. So, /apple\t*computer/ matches any number of tab characters between “apple” and “computer”, meaning it matches “apple\tcomputer” (one tab), “apple\t\tcomputer” (two tabs), or any number of tabs. Note it will also match “applecomputer” (no tabs) because * means zero or more.

Plus sign (+) means match the preceding item one or more times. So, /apple +computer/ matches if “apple” and “computer” are separated by 1 or more spaces.

Question mark (?) means the preceding item is optional, it may occur once or not at all. So in other words, the preceding item may match one time (if it’s there) or zero times (if it’s not). For example, /to-?do/ will match “todo” or “to-do”.

Parentheses (()) are used for grouping. So, /doh+/ will match “dohhhhhhhh”, but /(doh)+/ will match “dohdohdoh”.

Vertical bar (|) means “or”. Either the left side may match or the right side. So, /rtmp|rtmpe|rtmpt|rtmpte/ will match any string that contains “rtmp”, “rtmpe”, “rtmpt”, or “rtmpte”.

Square brackets ([]) allow you to specify a list of possible characters, known as a character class. It matches just one single character, but that one character may be any of the ones listed. For example /rtmp[tse]/ will match “rtmpt”, “rtmps”, or “rtmpe”. You can also specify a range of characters, such as [a-zA-z] to match any one letter out of that set of 52.
A caret (^) at the start of the character class negates it. So, for example, [^xyz] would match any single character except one of those three. Remember that hyphens (-) are special characters inside square brackets, so you would need to escape them, such as [^a\-c] which matches any character except for a, hyphen, or c.

Character class shortcuts (\d \w \s)
\d is the same as [0-9], it matches any digit.
\w is the same as [A-Za-z0-9_], it matches any letter, digit, or underscore.
\s is the same as [\f\t\n\r], it matches form-feed, tab, newline, carriage return, or the space character. Common uses include \s* to match any amount of whitespace (including none), and \s+ to match one or more whitespace characters.

Uppercase counterparts to the character class shortcuts (\D \W \S). These are equivalent to [^\d], [^\w], and [^\s], respectively. In other words, \D matches a non-digit character, \W a non-word character, and \S a non-whitespace character.
Tip: [\d\D] will match any digit, or any non-digit, meaning any character at all, even a newline character (as opposed to the dot (.) which matches any character except a newline.

Braces ({}) allow you to specify how many times the preceding item should match. So, {5} mean that the preceding item should be matched exactly 5 times. {5,} means it must be there at least 5 times and {5, 10} means it must be there at least 5 times but not more than 10.

Option Modifiers:

Case Insensitive Match (/i). To make a pattern case-insensitive, such as /yes/i

Match any character (/s). To make the dot (.) match newline characters, you can add the /s modifier, such as /hello.*world/s changes every dot in the pattern to act like the character class [\d\D], which is to match any character, even a newline character.

Note: you can combine these, such as /hello.*world/is

Anchors:

The caret (^) marks the beginning of the string, so /^http/ will match “http” only at the start of the string, it wouldn’t match “use the http protocol” for example.

The dollar sign ($) marks the end of a string, so /protocol$/ will match “use the http protocol”, it would not match “the http protocol is commonly used for …”.

The word boundary anchor (\b) matches at the start or end of a group of \w characters, so /rtmp\bte\b/ would match “rtmpte”, but not “rtmp” or “rtmpt”.

Reg Ex Tester App:

Enter a string to test a regular expression against. Since the reg ex strings are handed to the ActionScript class RegEx’s constructor, leave off the beginning ‘/’ and ending ‘/’ characters.  The “Search” button will show “true” or “false” in the results area, while the “Match” button shows the parse results returned by the “match” method on the ActionScript String class.  The sample provided here parses a URI into port, protocol, path, etc.