Adobe COLDFUSION 9 Manual page 143

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
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 a character set (for example [\b]), it specifies a backspace
\B
Specifies a boundary defined by no transition of character type. For example, two alphanumeric characters in a
row or two nonalphanumeric characters 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, or the underscore (_), similar to [[:word:]]
\W
Any nonalphanumeric character, except the underscore similar to [^[:word:]]
\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]
\\x
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
Using character classes
In character sets within regular expressions, you can include a character class. You enclose the character class inside
brackets, as the following example shows:
REReplace ("Adobe Web Site","[[:space:]]","*","ALL")
This code replaces all the spaces with *, producing this string:
Adobe*Web*Site
You can combine character classes with other expressions within a character set. For example, the regular expression
[[:space:]123] searches for a space, 1, 2, or 3. The following example also uses a character class in a regular expression:
<cfset IndexOfOccurrence=REFind("[[:space:]][A-Z]+[[:space:]]",
"Some BIG string")>
<!--- The value of IndexOfOccurrence is 5 --->
Last updated 8/5/2010
138

Advertisement

Table of Contents
loading

Table of Contents