%dw 2.0
import * from dw::core::Strings
output application/json
---
{
"a": repeat("e", 0),
"b": repeat("e", 3),
"c": repeat("e", -2)
}
DataWeave
repeat
repeat(text: String, times: Number): String
Repeats a text
the number of specified times
.
Introduced in DataWeave version 2.2.0.
Parameters
Name | Description |
---|---|
|
The input string. |
|
Number of times to repeat char. Negative is treated as zero. |
Example
This example shows how repeat
behaves with different inputs and sizes.
Source
Output
{
"a": "",
"b": "eee",
"c": ""
}
JSON
repeat(text: Null, times: Any): Null
Helper function that enables repeat
to work with a null
value.
Introduced in DataWeave version 2.4.0.