CFLib.org – Common Function Library Project

ListDeleteDuplicatesNoCase(list)

Last updated July 2, 2008

author

Jeff Howden

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Simply pass it a list and optional delimiter. The function will look for case-insensitive matches, removing any it finds, and return a new list without duplicates.

Return Values:
Returns a list.

Example:

<cfset myList = "apples,oranges,apples,bananas,ORANGES">

<cfoutput>
List before removing dupes: #myList#<br>
List after removing dupes: #ListDeleteDuplicatesNoCase(myList)#
</cfoutput>

Parameters:

Name Description Required
list List to be modified. Yes

Full UDF Source:

/**
 * Case-insensitive function for removing duplicate entries in a list.
 * Based on dedupe by Raymond Camden
 * 
 * @param list 	 List to be modified. (Required)
 * @return Returns a list. 
 * @author Jeff Howden (cflib@jeffhowden.com) 
 * @version 1, July 2, 2008 
 */
function ListDeleteDuplicatesNoCase(list) {
  var i = 1;
  var delimiter = ',';
  var returnValue = '';
  if(ArrayLen(arguments) GTE 2)
    delimiter = arguments[2];
  list = ListToArray(list, delimiter);
  for(i = 1; i LTE ArrayLen(list); i = i + 1)
    if(NOT ListFindNoCase(returnValue, list[i], delimiter))
      returnValue = ListAppend(returnValue, list[i], delimiter);
  return returnValue;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

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

Simon Bingham added
convertSecondsTo...
April 15, 2015

Created by Raymond Camden / Design by Justin Johnson