Contact Free trial Login

repeat

repeat(String, Number): String

Repeats a text the number of specified times.

Introduced in DataWeave 2.2.0. Supported by Mule 4.2 and later.

Parameters

Name Description

text

The input string.

times

Number of times to repeat char. Negative is treated as zero.

Example

This example shows how repeat behaves with different inputs and sizes.

Source

%dw 2.0
import * from dw::core::Strings
output application/json
---
{
  "a": repeat("e", 0),
  "b": repeat("e", 3),
  "c": repeat("e", -2)
}

Output

{
  "a": "",
  "b": "eee",
  "c": ""
}

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub