Solved

Removing duplicates from a ColdFusion list

Posted on 2011-09-06
4
289 Views
Last Modified: 2012-05-12
My variable qaEmails is list (with a ; delimiter) that may contain duplicates. It may look like this:

groulx@ttl.org; tfarris@ttl.org; mwelch@ttl.org; tfarris@ttl.org; mdm@ttl.org; bnelson@ttl.org; awetterberg@ttl.org; bnelson@ttl.org

I want to strip the duplicates out of the list. How would I do this?

Thanks!
0
Comment
Question by:traport
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
Bhavesh Shah earned 500 total points
ID: 36488460
Hi,

This cane be done by this way.(You must be knowing)
But I'm assuming you having lots of data, for that there is another method too, in case if you using SQL Server 2005

Let us know if you need anything more...

- Bhavesh
<cfoutput>
<cfset mail = "groulx@ttl.org; tfarris@ttl.org; mwelch@ttl.org; tfarris@ttl.org; mdm@ttl.org; bnelson@ttl.org; awetterberg@ttl.org; bnelson@ttl.org">

<cfset new_mail = "">

<cfloop list="#mail#" index="m" delimiters=";">
<cfif listfind(new_mail, m, ";") eq 0>
	<cfset new_mail = ListAppend(new_mail,m,";")>
</cfif>
</cfloop>

mail - #mail#<br />
new mail - #new_mail#

</cfoutput>

Open in new window

0
 

Author Closing Comment

by:traport
ID: 36488494
Worked beautifully - thank you!
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 36488662

Just in case two mails have different case settings, you may want to use listFindNoCase()  

 That would make   jSmith@gmail.com the same as jsmith@gmail.com

<cfif listfindNoCase(new_mail, m, ";") eq 0>
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 36488776
Hey,


Thank you sir for your information. =)

- Bhavesh
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
URL ReWrite configuration redirect all .htm to .cfm 8 158
CFLogin explained 10 85
Database set up 5 66
Problem with data displaying 2 22
PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 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

11 Experts available now in Live!

Get 1:1 Help Now