StringFilter()
Filters a string to its elements for which the callback function returns true.
Introduced: 6.0.0.105
StringFilter( string=string, closure=function );
Returns: String
| Argument | Description |
|---|---|
|
string
string,
required
|
edit
Input string. Alias: string |
|
closure
function,
required
|
edit
Closure or a function reference that will be called for each of the iteration. Alias: function, callback, udf |
Usage Notes
editSince Lucee 6, this function iterates over each character in the string.
For list-based iteration with delimiters, use ListFilter() instead.
Examples
edit letters = "abbcdB";
callbackFunction = function(input){return input=="b";}
result = stringFilter(letters,callbackFunction);
writeDump(result);
result1 = stringFilter("bob",callbackFunction);
writeDump(result1);
See also
- string.filter()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)