Parameter
Last updated on
Apr 27, 2021
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
|
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>