Solved

Compare two value lists and find ANY matches

Posted on 2006-06-22
3
207 Views
Last Modified: 2013-12-24
What is the best way to compare two value lists and return TRUE if  ANY matches are found.  For instance...

Value List #1 = Item1, Item3, Item5, Item7
Value List #2 = Item2, Item3, Item4

should return TRUE since Item3 in in both lists.

Thanks.
0
Comment
Question by:SiriusPhil
  • 2
3 Comments
 
LVL 7

Expert Comment

by:aseusainc
ID: 16963115
<cfset List1 = "Item1,Item3,Item5,Item7">
<cfset List2 = "Item2,Item3,Item4">

<cfset match = 0>
<cfloop list = #list2# index = x>
<cfif listcontains(#list1#,#x#)>
  <cfset match = 1>
</cfif>
</cfloop>

<cfoutput>#match#</cfoutput>

0=no match, 1=match
0
 
LVL 7

Accepted Solution

by:
aseusainc earned 500 total points
ID: 16963311
This may be better actually (use listfind instead of listcontains..my bad):

<cfset List1 = "Item1,Item3,Item5,Item7">
<cfset List2 = "Item2,Item3,Item4">

<cfset match = 0>
<cfloop list = #list2# index = x>
<cfif listfind(#list1#,#x#)>
  <cfset match = 1>
</cfif>
</cfloop>

<cfoutput>#match#</cfoutput>

0=no match, 1=match
0
 

Author Comment

by:SiriusPhil
ID: 16971967
Awsome.  Thanks.  I think I was just over engineering it.

Phil
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
XML problem with Internet Explorer 7 40
Internal DNS Zone Issue 13 60
How to stress test an ASP.NET https website 3 63
cookies analysis tools 2 72
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now