|
ListContains
DescriptionDetermines
the index of the first list element that contains a specified substring.
ReturnsIndex
of the first list element that contains substring. If not
found, returns zero.
Function syntaxListContains(list, substring [, delimiters, includeEmptyValues ])
Parameters
Parameter
|
Description
|
includeEmptyValues
|
Optional. Set to yes to
include empty values.
|
list
|
A list or a variable that contains one.
|
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.
|
UsageColdFusion
ignores empty list elements; thus, the list "a,b,c,,,d" has four
elements.
Example<!--- This example shows differences between ListContains and ListFind --->
<!--- Create a list composed of the elements one, two, three. ---->
<cfset aList = "one">
<cfset aList = ListAppend(aList, "two")>
<cfset aList = ListAppend(aList, "three")>
<p>Here is a list: <cfoutput>#aList#</cfoutput>
<p><strong>ListContains</strong> checks for substring "wo" in the list elements:
<cfoutput>
<p> Substring "wo" is in
<B>element #ListContains(aList, "wo")#</B> of list.
</cfoutput>
<p>ListFind cannot check for a substring within an element; therefore, in the
code, it does not find substring "wo" (it returns 0):
<cfoutput>
<p> Substring "wo" is in <b>element #ListFind(aList, "wo")#
</b> of the list.</cfoutput>
<p><p>If you specify a string that exactly equals an entire list element, such
as "two", both ListContains and ListFind find it, in the second element:
<p> <strong>ListContains</strong>:
<cfoutput>
The string "two" is in <b>element #ListContains(aList, "two")#</b> of the list.
</cfoutput>
<p><strong>ListFind</strong>:
<cfoutput>
The string "two" is in <b>element #ListFind(aList, "two")#</b> of the list.
</cfoutput>
|