Adobe COLDFUSION 9 Manual page 142

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Special Character
Description
(?i)
If at the beginning of a regular expression for
For example, the following line would return an index of 1:
#reFind("(?i)hi", "HI")#
If you omit the (?i), the line would return an index of zero to signify that it did not find the regular expression.
(?=...)
If at the beginning of a regular expression, it specifies to use positive lookahead when searching for the regular
expression.
Positive lookahead tests for the parenthesized subexpression like regular parenthesis, but does not include the
contents in the match - it merely tests to see if it is there in proximity to the rest of the expression.
For example, consider the expression to extract the protocol from a URL:
<cfset regex = "http(?=://)">
<cfset string = "http://">
<cfset result = reFind(regex, string, 1, "yes")>
mid(string, result.pos[1], result.len[1])
This example results in the string "http". The lookahead parentheses ensure that the "://" is there, but does not
include it in the result. If you did not use lookahead, the result would include the extraneous "://".
Lookahead parentheses do not capture text, so backreference numbering will skip over these groups. For more
information on backreferencing, see
(?!...)
If at the beginning of a regular expression, it specifies to use negative lookahead. Negative is just like positive
lookahead, as specified by (?=...), except that it tests for the absence of a match.
Lookahead parentheses do not capture text, so backreference numbering will skip over these groups. For more
information on backreferencing, see
(?:...)
If you prefix a subexpression with "?:", ColdFusion performs all operations on the subexpression except that it will
not capture the corresponding text for use with a back reference.
You must be aware of the following considerations when using special characters in character sets, such as [a-z]:
• To include a hyphen (-) in the brackets of a character set as a literal character, you cannot escape it as you can other
special characters because ColdFusion always interprets a hyphen as a range indicator. Therefore, if you use a literal
hyphen in a character set, make it the last character in the set.
• To include a closing square bracket (]) in the character set, escape it with a backslash, as in [1-3\]A-z]. You do not
have to escape the ] character outside the character set designator.
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, as [0-9] does. ColdFusion
escape sequences are case sensitive.
The following table lists the escape sequences that ColdFusion supports:
REFind()
, it specifies to perform a case-insensitive compare.
"Using
backreferences" on page 139.
"Using
backreferences" on page 139.
Last updated 8/5/2010
137

Advertisement

Table of Contents
loading

Table of Contents