Adobe ColdFusion 8

Using escape sequences

Escape sequences are special characters in regular expressions preceded by a backslash (\). You typically use escape sequences to represent special characters within a regular expression. For example, the escape sequence \t represents a tab character within the regular expression, and the \d escape sequence specifies any digit, similar to [0-9]. In ColdFusion the escape sequences are case-sensitive.

The following table lists the escape sequences that ColdFusion supports:

Escape Sequence

Description

\b

Specifies a boundary defined by a transition from an alphanumeric character to a nonalphanumeric character, or from a nonalphanumeric character to an alphanumeric character.

For example, the string " Big" contains boundary defined by the space (nonalphanumeric character) and the "B" (alphanumeric character).

The following example uses the \b escape sequence in a regular expression to locate the string "Big" at the end of the search string and not the fragment "big" inside the word "ambiguous".

reFindNoCase("\bBig\b", "Don't be ambiguous about Big.")

<!--- The value of IndexOfOccurrence is 26 --->

When used inside of a character set (e.g. [\b]), it specifies a backspace

\B

Specifies a boundary defined by no transition of character type. For example, two alphanumeric character in a row or two nonalphanumeric character in a row; opposite of \b.

\A

Specifies a beginning of string anchor, much like the ^ special character.

However, unlike ^, you cannot combine \A with (?m) to specify the start of newlines in the search string.

\Z

Specifies an end of string anchor, much like the $ special character.

However, unlike $, you cannot combine \Z with (?m) to specify the end of newlines in the search string.

\n

Newline character

\r

Carriage return

\t

Tab

\f

Form feed

\d

Any digit, similar to [0-9]

\D

Any nondigit character, similar to [^0-9]

\w

Any alphanumeric character, similar to [[:alnum:]]

\W

Any nonalphanumeric character, similar to [^[:alnum:]]

\s

Any whitespace character including tab, space, newline, carriage return, and form feed. Similar to [ \t\n\r\f].

\S

Any nonwhitespace character, similar to [^ \t\n\r\f]

\xdd

A hexadecimal representation of character, where d is a hexadecimal digit

\ddd

An octal representation of a character, where d is an octal digit, in the form \000 to \377