stringEvery

Determines if all elements of a string satisfy a given condition. Will return TRUE is all elements meet the condition, else FALSE.

stringEvery(string,callback) → returns boolean

Member Function Syntax

string.every(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. The syntax is callback(element,index,string).

Compatibility

Lucee:

Version 6+ This function is being added in Lucee 6. Similar to structEvery() and arrayEvery().

Links more information about stringEvery

Examples
Sample code invoking the stringEvery function

Do all letters in the string meet the callback condition?

letters="ZZazz";
callback=function(inp){return inp=="z";}
allZs = StringEvery(letters,callback);
writeOutput(allZs)

Expected Result: NO

Do all letters in the string meet the callback condition?

letters="zzZZz";
callback=function(inp){return inp=="z";}
allZs = letters.every(callback);
writeOutput(allZs)

Expected Result: YES

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

Fork me on GitHub