Contact Form

Name

Email *

Message *

Cari Blog Ini

Cfml Contains

Determine List Element Index with Substring

Quickly Find Substrings in Lists

The CONTAINS operator in Lucee allows developers to efficiently search for substrings within a list. The CONTAINS operator returns the index of the first element in the list that includes the specified substring.

Example Usage

   

In this example, the INDEXOF function returns 4, as "Dog" is the fourth element in the list.

Variations and Options

The CONTAINS operator also supports the DOES NOT CONTAIN (NCT) operator, which returns TRUE if the substring is not present in the list, and FALSE if it is.

Lucee provides convenient shorthand tags for CONTAINS (CT) and DOES NOT CONTAIN (NCT) operators. These streamlined tags make it easier to perform substring searches.

Conclusion

The CONTAINS operator is a powerful tool for quickly determining the presence of substrings within lists. Its concise syntax and efficient performance make it an essential addition to any Lucee developer's toolkit, empowering them to create sophisticated and dynamic applications with ease.


Comments