listGetDuplicates

Returns a list of the values that appear more than once in a list. Each repeated value is returned once, in the order of its first repeat.

listGetDuplicates(list [, delimiter [, ignoreCase [, includeEmptyFields]]]) → returns string

Argument Reference

list string
Required

The list to search.

delimiter string
Default: ,

The delimiter. ColdFusion treats the whole string as one delimiter, so ;, only splits on ;,; Lucee treats each character as a delimiter. The result is joined with the full delimiter string.

ignoreCase boolean
Default: false

If true, values that differ only in case count as duplicates. The default is case-sensitive. Adobe's docs describe this argument the wrong way round.

includeEmptyFields boolean
Default: false

If true, empty elements are included, so a repeated empty element appears in the result as an empty item.

Examples
Sample code invoking the listGetDuplicates function

Returns each value that appears more than once.

listGetDuplicates("1,2,2,5,5,1,3")

Expected Result: 2,5,1

With ignoreCase true, one and ONE count as duplicates.

listGetDuplicates("one,two,ONE,three,THREE", ",", true)

Expected Result: ONE,THREE

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub