Solved

Removing duplicates from a ColdFusion list

Posted on 2011-09-06
4
286 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

10 Experts available now in Live!

Get 1:1 Help Now