Contact Us 1-800-596-4880

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": ""
}