CompareNoCase

Description

Performs a case-insensitive comparison of two strings. Returns:

Category

String functions

Syntax

CompareNoCase(string1, string2) 

See also

Compare, FindNoCase

Parameters

Parameter
Description
string1, string2
Strings to compare

Example

<!--- This example shows the use of CompareNoCase --->
<html>
<head>
<title> CompareNoCase Example </title>
</head>
<body bgcolor = silver>

<H3>CompareNoCase Example</H3>
<P>The compare 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>