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