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
Solved

Compare two value lists and find ANY matches

Posted on 2006-06-22
3
210 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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