%dw 2.0
import * from dw::core::Strings
output application/json
---
"42 = 11 * 2 + 20" countCharactersBy isNumeric($)
DataWeave
countCharactersBy
countCharactersBy(text: String, predicate: (character: String) -> Boolean): Number
Counts the number of times an expression that iterates through
each character in a string returns true
.
Introduced in DataWeave version 2.4.0.
Parameters
Name | Description |
---|---|
|
The string to which the |
|
Expression to apply to each character in the
|
Example
This example counts the digits in a string.
Source
Output
7
Json
countCharactersBy(text: Null, predicate: (character: Nothing) -> Any): Null
Helper function to make countCharactersBy
work with a null
value.
Introduced in DataWeave version 2.4.0.