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);
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson