Using Regular Expressions In Functions - Adobe 38043740 - ColdFusion Standard - Mac Development Manual

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Code
if (StructKeyExists(rejectCode,applicant)) {
switch(rejectCode[applicant]) {
case "score":
WriteOutput("Reject reason: Score was too low.<br>");
break;
case "late":
WriteOutput("Reject reason: Application was late.<br>");
break;
default:
WriteOutput("Rejected with invalid reason code.<br>");
} //end switch
} //end if
else {
WriteOutput("Reject reason was not defined.<br>");
} //end else
WriteOutput("<br>");
} //end for
</cfscript>

Using Regular Expressions in Functions

Regular expressions let you perform string matching operations using Adobe ColdFusion functions; in particular.
regular expressions work with the following functions:
REFind
REFindNoCase
REMatch
REMatchNoCase
REReplace
REReplaceNoCase
Regular expressions used in the
slightly different syntax than ColdFusion regular expressions. For information on JavaScript regular expressions, see
"Building Dynamic Forms with cfform
About regular expressions
In traditional string matching, as used by the ColdFusion
to search for and the string to search. The following example searches a string for the pattern " BIG " and returns a
string index if found. The string index is the location in the search string where the string pattern begins.
<cfset IndexOfOccurrence=Find(" BIG ", "Some BIG string")>
<!--- The value of IndexOfOccurrence is 5 --->
You must provide the exact string pattern to match. If the exact pattern is not found,
Because you must specify the exact string pattern to match, matches for dynamic data can be difficult, if not impossible,
to construct.
and
cfinput
cftextinput
Tags" on page 722.
Find
Last updated 1/20/2012
Description
Checks the
rejectCode
for the applicant.
If a code exists, enters a switch statement that examines
the rejection code value.
If the rejection code value matches one of the known
codes, displays an expanded explanation of the
meaning. Otherwise (the default case), displays an
indication that the rejection code is not valid.
Comments at the end of blocks help clarify the control
flow.
If there is no entry for the applicant in the
structure, displays a message indicating that the reason
was not defined.
Displays a blank line after each rejected applicant.
Ends the for loop that handles each rejected applicant.
Ends the CFScript.
tags are JavaScript regular expressions, which have a
and
functions, you provide the string pattern
Replace
Find
structure for a rejection code
rejectCode
returns an index of 0.
131

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents