StringEvery

Description

Determines if all elements of a string satisfy a given condition.

Returns

Boolean. True if all elements match a condition; false, otherwise.

Syntax

StringEvery(String string, UDFMethod callback)

Category

History

ColdFusion (2021 release): Added this function.

Parameters

Parameter

Description

string

(Required) The input string in which all elements are to be searched.

callback

(Required) Function that encapsulates criteria.

Example

<cfscript> 
    myString="123456789" 
    // define callback 
    callback=function(chr){ 
        return chr>5 
    } 
    writeOutput(StringEvery(myString,callback)) // YES 
     
    // define another callback 
    callback_1=function(chr){ 
        return chr<1 
    } 
    writeOutput(StringEvery(myString,callback_1)) // NO 
</cfscript>

Example 2

<cfscript> 
    myString="Hello" 
    // define callback 
    callback=x=>x >= 'a' 
    writeOutput(StringEvery(myString,callback)) // YES 
    // define another callback 
    callback_1=x=>x >= 'z' 
    writeOutput(StringEvery(myString,callback_1)) // NO 
</cfscript>

Get help faster and easier

New user?