Skip to content

Instantly share code, notes, and snippets.

@randy-johnson
Created August 21, 2011 00:52
Show Gist options
  • Save randy-johnson/1159915 to your computer and use it in GitHub Desktop.
Save randy-johnson/1159915 to your computer and use it in GitHub Desktop.
Using the COMPARENOCASE Function to Compare Strings in Coldfusion
<!---
Title: String Comparison Using the CompareNoCase Function.
From: Coldfusion By Example
Website: http://www.randy.cc/
Date: 8/20/2011
--->
<!--- Set variables for testing --->
<cfset string1 = "Randy">
<cfset string2 = "RANDY">
<cfset string3 = "Johnson">
<cfset string4 = "Johnson">
<cfoutput>
<!--- CompareNoCase: Case Insensitive --->
<p>
<cfif COMPARENOCASE(string1,string2) is 0>
"#string1#" is equal to "#String2#"
<cfelse>
"#String1#" is not equal to #string2#
</cfif>
</p>
<p>
<cfif COMPARENOCASE(string1,string3) is 0>
"#string1#" is equal to "#String3#"
<cfelse>
"#String1#" is not equal to #string3#
</cfif>
</p>
<p>
<cfif COMPARENOCASE(string3,string4) is 0>
"#string3#" is equal to "#String4#"
<cfelse>
"#String3#" is not equal to #string4#
</cfif>
</p>
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment