everyCharacter

everyCharacter(text: String, condition: (character: String) -> Boolean): Boolean

Checks whether a condition is valid for every character in a string.

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

text

The string to check.

condition

Expression that iterates through the characters in the string that it checks and returns a Boolean value.

Example

This example determines whether a string is composed of only digits and spaces.

Source

%dw 2.0
import everyCharacter from dw::core::Strings
output application/json
---
"12 34  56" everyCharacter $ == " " or isNumeric($)

Output

true

everyCharacter(text: Null, condition: (character: Nothing) -> Any): true

Helper function that enables everyCharacter to work with a null value.

Introduced in DataWeave version 2.4.0.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub