stringFilter

This function uses the callback to filter the elements in a string.

stringFilter(string,callback) → returns string

Member Function Syntax

string.filter(callback)

Argument Reference

string string
Required

Original input string to search.

callback any
Required

The closure function that is executed for each element in the string.

Compatibility

Lucee:

Version 6+ This function is being added in Lucee 6. It is similar to the other Lucee .filter() functions.

Links more information about stringFilter

Examples
Sample code invoking the stringFilter function

Return only the letters in the string that meet the callback condition.

letters="zzQQZ";
callback=function(inp){return inp=="z";}
onlyZs = StringFilter(letters,callback);
writeOutput(onlyZs);

Expected Result: zzZ

Return only the letters in the string that meet the callback condition.

letters="zzQQZ";
callback=function(inp){return inp=="z";}
onlyZs = letters.filter(callback);
writeOutput(onlyZs);

Expected Result: zzZ

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub