Regular Expression Syntax (Scripting)

Post date: Oct 22, 2014 1:38:35 AM

A regular expression describes one or more strings to match when you search a body of text. The expression serves as a template for matching a character pattern to the string that is being searched.

A regular expression consists of ordinary characters (for example, letters a through z) and special characters, known asmetacharacters.

Special Characters

The following table contains a list of single-character metacharacters and their behavior in regular expressions.

Note:

To match one of these special characters, you must first escape the character, that is, precede it with a backslash character (\). For instance, to search for the "+" literal character, you can use the expression "\+".

Most special characters lose their meaning and represent ordinary characters when they occur inside a bracket expression. For more information, see "Characters in Bracket Expressions" in Lists of Matching Characters (Scripting).

Metacharacters

The following table contains a list of multiple-character metacharacters and their behavior in regular expressions.

Nonprinting Characters

The following table contains escape sequences that represent non-printing characters.

Order of Precedence

A regular expression is evaluated much like an arithmetic expression; that is, it is evaluated from left to right and follows an order of precedence.

The following table contains the order of precedence of the regular expression operators, from highest to lowest.

Characters have higher precedence than the alternation operator, which, for example, allows "m|food" to match "m" or "food"