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

ListContains

Last update:
May 18, 2026

Description

Determines the index of the first list element that contains a specified substring.

Returns

Index of the first list element that contains  substring . If not found, returns zero.
History
ColdFusion (2018 Release): Introduced named parameters.
Category

Function syntax

ListContains(list, substring [, delimiters, includeEmptyFields ])

See also

ListContainsNoCaseListFindLists in Data types- Developing guide in the Developing ColdFusion Applications

Parameters

Parameter
Description
includeEmptyFields
Optional. Set to yes to include empty values.
list
A list or a variable that contains the list.
substring
A string or a variable that contains one. The search is case sensitive.
delimiters
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.

Usage

ColdFusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements.

Example

<cfscript>
       myList="Tokyo,Bangkok,Jakarta,Manila,Bangalore,Shanghai";
       WriteOutput(ListContains(myList,"Bangkok") & " | "); // Returns 2 since index of Bangkok is 2
       WriteOutput(ListContains(myList,"Singapore")); // Returns 0 since Singapore is not a part of the list
</cfscript>
Output
2 | 0

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