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; Evaluation and type conversion issues in Data type conversion in the Developing ColdFusion Applications

Parameters

Parameter

Description

string1

A string or a variable that contains one

string2

A string or a variable that contains one

Example

<cfscript>
    myString1="ColdFusion"
    myString2="Coldfusion"
    myString3="ColdFusion (2016 release)"
    myString4="ColdFusion (2018 release)"
    writeOutput(CompareNoCase(myString1,myString2) & "<br/>") // Returns 0
    writeOutput(CompareNoCase(myString3,myString4) & "<br/>") // Returns -1
    writeOutput(CompareNoCase(myString4,myString3) & "<br/>") // Returns 1
</cfscript>

Output

0
-1
1

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy