User Guide

Table Of Contents
48 Chapter 3: Using ColdFusion Variables
Escaping quotation marks and number signs
To include a single-quotation character in a string that is single-quoted, use two single-quotation
marks (known as escaping the single-quotation mark). The following example uses escaped single-
quotation marks:
<cfset myString='This is a single-quotation mark: '' This is a double-quotation
mark: "'>
<cfoutput>#mystring#</cfoutput><br>
To include a double-quotation mark in a double-quoted string, use two double-quotation marks
(known as escaping the double-quotation mark). The following example uses escaped double-
quotation marks:
<cfset myString="This is a single-quotation mark: ' This is a double-quotation
mark: """>
<cfoutput>#mystring#</cfoutput><br>
Because strings can be in either double-quotation marks or single-quotation marks, both of the
preceding examples display the same text:
This is a single-quotation mark: ' This is a double-quotation mark: "
To insert a number sign (#) in a string, you must escape the number sign, as follows:
"This is a number sign ##"
Lists
ColdFusion includes functions that operate on lists, but it does not have a list data type. In
ColdFusion, a list is just a string that consists of multiple entries separated by delimiter characters.
The default delimiter for lists is the comma. If you use any other character to separate list
elements, you must specify the delimiter in the list function. You can also specify multiple
delimiter characters. For example, you can tell ColdFusion to interpret a comma or a semicolon as
a delimiter, as the following example shows:
<cfset MyList="1,2;3,4;5">
<cfoutput>
List length using ; and , as delimiters: #listlen(Mylist, ";,")#<br>
List length using only , as a delimiter: #listlen(Mylist)#<br>
</cfoutput>
This example displays the following output:
List length using ; and , as delimiters: 5
List length using only , as a delimiter: 3
Each delimiter must be a single character. For example, you cannot tell ColdFusion to require two
hyphens in a row as a delimiter.
If a list has two delimiters in a row, ColdFusion ignores the empty element. For example, if
MyList is "1,2,,3,,4,,,5" and the delimiter is the comma, the list has five elements and list
functions treat it the same as "1,2,3,4,5".