Whatever message this page gives is out now! Go check it out!

ListGetDuplicates

Last update:
May 18, 2026

Description

Returns duplicate items in a list.

Returns

A new list

Category

Syntax

listGetDuplicates(list,delimiter,ignoreCase,includeEmptyFields)

See also

Other list functions.

History

  • ColdFusion (2021 release): Added the function.

Parameters

Parameter
Description
list
Name of the list object.
delimiter
(String) A string or a variable that contains one. Characters that separate list elements. The default value is comma. If this parameter contains more than one character, ColdFusion processes each occurrence of each character as a delimiter.
ignoreCase
(True/False) If true, the function performs a case-sensitive string search.
includeEmptyFields(True/False) if true, the function ignores blank values in the list.

Example

<cfscript>
    list1 = "one,one,ONE,two,three,,four,THREE,FOUR,FIVE,";
    newList1 = listgetduplicates(list=list1,delimiter=",",ignorecase=true);
    writeoutput(newlist1)
</cfscript>
Output
one,THREE,FOUR

Example ignoreCase=FALSE

<cfscript>
    list1 = "one,one,ONE,two,three,,four,THREE,FOUR,FIVE,";
    newList1 = listgetduplicates(list=list1,delimiter=",",ignorecase=false);
    writeoutput(newlist1)
</cfscript>
Output
one

Example- numeric list

<cfscript> 
  list1 = "1, 2, 22, 3, 2, 5, 5, 1"; 
  newList1 = listgetduplicates(list=list1); 
  writeOutput(newlist1) 
</cfscript>
Output
2,5,1

Example- dashed list

<cfscript> 
  list1 = "1-2-22-3-2-5-5-1"; 
  newList1 = listgetduplicates(list=list1, delimiter="-"); 
  writeOutput(newlist1) 
</cfscript>
Output
2-5-1

Example- includeemptyfields=true

<cfscript>
  list1 = "one,one,ONE,two,three,,,four,THREE,FOUR,FIVE,";
  newList1 = listgetduplicates(list=list1,delimiter=",",ignorecase=true,includeemptyfields=true);
  writeOutput(newlist1)
</cfscript>
Output
one,,THREE,FOUR

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page