User Guide
Regular expression syntax 293
You can also use the \xnn ASCII character code to specify a range by ASCII value. For
example, the following character class matches any character from a set of extended ASCII
characters (such as
é and ê):
/[\x80-\x9A]/
Negated character classes
When you use a caret (^) character at the beginning of a character class, it negates that class—
any character not listed is considered a match. The following character class matches any
character except for a lowercase letter (
a–z) or a digit:
/[^a-z0-9]/
You must type the caret (^) character at the beginning of a character class to indicate negation.
Otherwise, you are simply adding the caret character to the characters in the character class.
For example, the following character class matches any one of a number of symbol characters,
including the caret:
/[!.,#+*%$&^]/
Quantifiers
You use quantifiers to specify repetitions of characters or sequences in patterns, as follows:
You can apply a quantifier to a single character, to a character class, or to a group:
■ /a+/ matches the character a repeated one or more times.
■ /\d+/ matches one or more digits.
■ /[abc]+/ matches a repetition of one or more character, each of which is either a, b, or c.
■ /(very, )*/ matches the word very followed by a comma and a space repeated zero or
more times.
Quantifier
metacharacter
Description
* (star) Matches the previous item repeated zero or more times.
+ (plus) Matches the previous item repeated one or more times.
? (question mark) Matches the previous item repeated zero times or one time.
{n}
{n,}
and
{n,n}
Specifies a numeric quantifier or quantifier range for the previous item:
/A{27}/ matches the character A repeated 27 times.
/A{3,}/ matches the character A repeated 3 or more times.
/A{3,5}/ matches the character A repeated 3 to 5 times.