Solved

Compare two value lists and find ANY matches

Posted on 2006-06-22
3
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

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…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

735 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