%dw 2.0
import * from dw::core::Strings
output application/json
var text = "hello world!"
---
substring(text, 1, 5)
DataWeave
substring
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.
Parameters
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. |
Example
This example returns the substring with characters at indices
1
through 4
in the input string.
Source
Output
"ello"
json
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.