Skip to content

Instantly share code, notes, and snippets.

@randy-johnson
Created August 21, 2011 00:14
Show Gist options
  • Save randy-johnson/1159876 to your computer and use it in GitHub Desktop.
Save randy-johnson/1159876 to your computer and use it in GitHub Desktop.
Comparing Strings In Coldfusion
<cfset string1 = "Randy">
<cfset string2 = "RANDY">
<cfoutput>
<!--- IS: Case Insensitive --->
<p><cfif string1 is string2>
"#string1#" is equal to "#String2#"
<cfelse>
"#String1#" is not equal to #string2#
</cfif></p>
<!--- EQ: Case Insensitive--->
<p><cfif string1 EQ string2>
"#string1#" is equal to "#String2#"
<cfelse>
"#String1#" is not equal to #string2#
</cfif></p>
<!--- Compare: Case Insensitive --->
<p><cfif compareNoCase(string1,string2) is 0>
"#string1#" is equal to "#String2#"
<cfelse>
"#String1#" is not equal to #string2#
</cfif></p>
<!--- Compare: Case Sensitive --->
<p><cfif compare(string1,string2) is 0>
"#string1#" is equal to "#String2#"
<cfelse>
"#String1#" is not equal to #string2#
</cfif></p>
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment