Solved

Removing duplicates from a ColdFusion list

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

770 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