CompareNoCase() - compare two strings (case insensitive)
CompareNoCase.cfm
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CompareNoCase function example: how to compare two strings (case insensitive)</title>
</head>
<body>
<h2 style="color:hotpink">CompareNoCase Function Example</h2>
<cfset String1="John">
<cfset String2="john">
<cfoutput>
<b>
String1: #String1#
<br />
String2: #String2#
</b>
<br />
</cfoutput>
<cfset StringCompareResult=CompareNoCase(String1,String2)>
Result:
<cfif StringCompareResult EQ 0>
Two strings are equal
<cfelseif StringCompareResult LT 0>
String1 is less than String2
<cfelse>
String1 is greater than String2
</cfif>
<br /><br />
<cfset String1="Ben">
<cfset String2="John">
<cfoutput>
<b>
String1: #String1#
<br />
String2: #String2#
</b>
<br />
</cfoutput>
<cfset StringCompareResult=CompareNoCase(String1,String2)>
Result:
<cfif StringCompareResult EQ 0>
Two strings are equal
<cfelseif StringCompareResult LT 0>
String1 is less than String2
<cfelse>
String1 is greater than String2
</cfif>
</body>
</html>
- Asc() - get the value of a character
- Compare() - compare two strings (case sensitive)
- Find() - find the first occurence of a substring in a string (case sensitive)
- RepeatString()
- Replace() - replace a substring in a string (case sensitive)
- Reverse() - reverse chracters in a string or digits in a number
- Right() - get the rightmost count characters in a string
- RTrim() - remove spaces from the end of a string
- Trim() - remove leading and trailing spaces from a string
- UCase() - convert a string to uppercase