CFLib.org – Common Function Library Project

ListReturnDuplicates(list[, delimiter])

Last updated October 18, 2008

author

Gerald Guido

Version: 0 | Requires: CF5 | Library: StrLib

Description:
Searches a list for case- sensitive Duplicates and returns a list of the duplicate items or and empty string if no dupes are found. Based on Jeff Howden's' ListDeleteDuplicates()

Return Values:
Returns a string.

Example:

Example:
<cfset myList = "Sister,Ghengis,Adonis,Osmisis,Frank,Zappa,sister,ghengis,adonis,osmisis,Frank,Zappa">


<cfoutput>
List of case-sensitive dupes:
<br />#ListReturnDuplicates(myList)#
</cfoutput>

Parameters:

Name Description Required
list List to parse. Yes
delimiter List delimiter. Defaults to a comma. No

Full UDF Source:

/**
 * Searches a list for case- sensitive Duplicates and returns a list of the duplicate items or an empty string if no dupes are found.
 * 
 * @param list 	 List to parse. (Required)
 * @param delimiter 	 List delimiter. Defaults to a comma. (Optional)
 * @return Returns a string. 
 * @author Gerald Guido (Gerald.Guido@gmail.com) 
 * @version 0, October 18, 2008 
 */
function ListReturnDuplicates(list) {
	var i = 1;
	var delimiter = ',';
	var returnValue1 = '';
	var tmpList = list;

	if(arrayLen(arguments) GTE 2) delimiter = arguments[2];
	list = ListToArray(list, delimiter);
	for(i = 1; i LTE ArrayLen(list); i = i + 1) if(ListValueCount(tmpList, list[i]) GT 1 and not listFind(returnValue1,list[i],delimiter)) returnValue1 = ListAppend(returnValue1, list[i], delimiter);

	return returnValue1;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson