User Guide

CompareNoCase 519
CompareNoCase
Description
Performs a case-insensitive comparison of two strings.
Returns
An indicator of the difference:
A negative number, if string1 is less than string2
0, if string1 is equal to string2
A positive number, if string1 is greater than string2
Category
String functions
Function syntax
CompareNoCase(string1, string2)
See also
Compare
, FindNoCase; “Ambiguous type expressions and strings” in Chapter 3, “Using
ColdFusion Variables,” in ColdFusion MX Developers Guide
Parameters
Example
<H3>CompareNoCase Example</H3>
<P>This function performs a <I>case-insensitive</I> comparison of two strings.
<CFIF IsDefined("form.string1")>
<CFSET comparison = Comparenocase(form.string1, form.string2)>
<!--- switch on the variable to give various responses --->
<CFSWITCH EXPRESSION=#comparison#>
<CFCASE value="-1">
<H3>String 1 is less than String 2</H3>
<I>The strings are not equal</I>
</CFCASE>
<CFCASE value="0">
<H3>String 1 is equal to String 2</H3>
<I>The strings are equal!</I>
</CFCASE>
<CFCASE value="1">
<H3>String 1 is greater than String 2</H3>
<I>The strings are not equal</I>
</CFCASE>
<CFDEFAULTCASE>
<H3>This is the default case</H3>
</CFDEFAULTCASE>
Parameter Description
string1 A string or a variable that contains one
string2 A string or a variable that contains one