substringEvery(text: String, amount: Number): Array<String>

Splits a string into an array of substrings equal to a specified length.

The last substring can be shorter than that length. If the length is greater than or equal to the length of the string to split, the function returns the entire string.

Introduced in DataWeave version 2.4.0.


Name Description


The string to split.


The desired length of each substring.


This example shows how substringEvery behaves when splitting an input string. The last returned substring is shorter than the others.


%dw 2.0
import substringEvery from dw::core::Strings
output application/json
substringEvery("substringEvery", 3)


["sub", "str", "ing", "Eve", "ry"]

substringEvery(text: Null, amount: Any): Null

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

Introduced in DataWeave version 2.4.0.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub
Submit your feedback!
Share your thoughts to help us build the best documentation experience for you!
Take our latest survey!