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

StringFilter

Last update:
May 18, 2026

Description

Filters a string to its elements for which the callback function returns true.

Returns

A new string.

Category

Syntax

StringFilter(String string, UDFMethod callback)

History

ColdFusion (2021 release): Added this function.

Parameters

Parameter
Description
string
(Required) The input string
callback
(Required) Inline function executed for each element in the string. Returns true if the string element has to be included in the resultant string.

Example

<cfscript> 
    myStr="diamonds" 
    callback=function(chr){ 
        return chr>"d" 
    } 
    writeOutput(StringFilter(myStr,callback)) // imons 
</cfscript>

Example 2

<cfscript> 
    myStr="123456789" 
    callback=function(chr){ 
        return chr>53 
    } 
    writeOutput(StringFilter(myStr,callback)) // 6789 
</cfscript>

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