Skip to main content

Comparing Strings in Coldfusion

Comparing strings and numbers is one of the most common things you do when programming in any language.  Coldfusion is no different.

Here are four of the most common ways to compare strings in Coldfusion.
  1. IS operator
  2. EQ operator
  3. CompareNoCase function
  4. Compare function


Just like it sounds, you can use the IS operator.

Is variable1 equal to variable2?

This type of comparison is case insensitive.


The EQ operator is similar to the IS operator.  Again this is case insensitive.

METHOD 3: Compare Function

The compare function is used to do a case sensitive comparison of two strings.  If the strings are the same this function will return 0.  If the strings are different the function will return -1 if the first string is less than the second string or 1 if the first string is greater than the second string.  The 1 and -1 one come in handy if you are using the compare function to compare numbers.

METHOD 4: CompareNoCase

The CompareNoCase function works the same way as Compare except it is a case insensitive search.


The above methods also work for numbers.  Switch out the examples with numbers too see the output.

Popular posts from this blog

Boy I wish there was a way to create a table from a select query

I was doing some SQL work today when I had a thought: Boy I wish there was a way to create a table from a select query I started in Navicat to see if it was possible.  After find nothing I decided to google it all the while thinking in my head how I was going to create a script to do this if I couldn't find anything. I found something. I was happy yet sad.  Happy because I didn't have to take the time to create something.  Sad because I didn't have to create the tool.  It sounded like a fun project. What did I find you ask? The "Create Table as" statement. CREATE TABLE [ IF NOT EXISTS ] new_table [ AS ] SELECT expressions FROM existing_tables [WHERE conditions]; The best part about it is the statement knows to go to the existing tables to get the column type, size etc.   Such a tremendous time saver.  I cannot believe in all my years of programming I never stumbled upon this type of statement. Source: Tech on the Net

UPS - User Id and Shipper Number combination is not qualified to receive negotiated rates.

Today I started to receive the following message from the UPS API: User Id and Shipper Number combination is not qualified to receive negotiated rates. and to make matters worse, the result of this issue caused the checkout process to error preventing our customers from finishing their orders. So after doing a little research on my end I ended up calling the UPS technical support phone number for the United States: Over the phone we went over the following steps: UPS.COM You must add and authenticate your account using Account Summary to view Negotiated Rates in UPS Internet Shipping, Time and Cost Calculator on, and the UPS Developer Kit - Shipping and Rating APIs. To add and authenticate an account: 1. Login to using your My UPS ID and password. 2. Select the My UPS tab at the top of the page. 3. Select Account Summary from the navigation menu or the tab rollover. 4. From there select Add an Existing UPS Account. 5. Follow the steps to authenticate the account. To aut

Git GUI for Windows

This past weekend I needed to upload code to github.  I chose to use the GitHub for Windows which made it painless. Today I decided to research and see what other GUI clients I could find for GIT. I stumbled upon SourceTree  by Atlassian Software. It was really easy to setup a local repository as well as connecting to GitHub. My favorite feature so far besides the ease of use is the dashboard that shows you the files that need committed and the diff details right beside it. Here is a screenshot: