CFLib.org – Common Function Library Project

nodupslist(str[, delim])

Last updated May 30, 2010

author

Tony Bentley

Version: 1 | Requires: CF6 | Library: StrLib

Description:
Removes all duplicate values from a list. The function is case sensitive so A,a,a will return A,a.

Return Values:
Returns a string.

Example:

<cfoutput>#nodupslist("a|a|a|a|b|b|B|","|")#</cfoutput>

returns b|B|a

Parameters:

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

Full UDF Source:

/**
 * Remove duplicate values from a list.
 * 
 * @param str 	 List to parse. (Required)
 * @param delim 	 List delimiter. Defaults to a comma. (Optional)
 * @return Returns a string. 
 * @author Tony Bentley (tony@tonybentley.com) 
 * @version 1, May 30, 2010 
 */
function nodupslist(str){
	var delim = ",";
	if(arrayLen(arguments) is 2) delim = arguments[2];
	return arrayToList(createObject("java","java.util.HashSet").init(ListToArray(str,delim)).ToArray(),delim);
}
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