substring(text: String, from: Number, until: Number): String

Returns a substring that spans from the character at the specified from index to the last character before the until index.

The characters in the substring satisfy the condition from <= indexOf(string) < until.

Introduced in DataWeave version 2.4.0.


Name Description


The string, treated as an array of characters.


The lowest index to include from the character array.


The lowest index to exclude from the character array.


This example returns the substring with characters at indices 1 through 4 in the input string.


%dw 2.0
import * from dw::core::Strings
output application/json
var text = "hello world!"
substring(text, 1, 5)



substring(text: Null, from: Any, until: Any): Null

Helper function that enables substring 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!