Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Removing duplicates from a ColdFusion list

Posted on 2011-09-06
4
Medium Priority
?
318 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 2000 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 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 …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month7 days, 13 hours left to enroll

824 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