StringSome

Description

This function calls a given closure/function with every element in a given string and returns true, if one of the closure calls returns true.

Returns

Boolean

Category

Syntax

StringSome(inputString, callback)

History

ColdFusion (2021 release): Added in this release.

Parameters

Parameter

Description

inputString

(Required) The string to iterate.

callback

(Optional) Function that encapsulates the criteria.

Example

<cfscript> 
    myString="123456789"; 
    callback=function(num){ 
        return num>53 
    } 
    writeOutput(StringSome(myString,callback)) // YES 
</cfscript>

Example 2

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

Sign in to your account