---
schema_version: "1"
id: 8c3334e29a67ba8a3f99f18875354830273bfaba8d891caec85001a7c4800d9d
title: repeat
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.11/dw-strings-functions-repeat.md
canonical_url: https://docs.mulesoft.com/dataweave/2.11/dw-strings-functions-repeat
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 39f78187c0a60d6985537fa9c5ec5c221da910a87a987fd0186eb6134691ae1b
description: MuleSoft Documentation Site
release: "2.11"
latest: false
---
---
product: DataWeave
version: 2.11
---

# repeat

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## repeat(text: String, times: Number): String

Repeats a `text` the number of specified `times`.

_Introduced in DataWeave version 2.2.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>text</code></p></td><td><p>The input string.</p></td></tr><tr><td><p><code>times</code></p></td><td><p>Number of times to repeat char. Negative is treated as zero.</p></td></tr></tbody></table>

### Example

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

#### Source

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

#### Output

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

## repeat(text: Null, times: Any): Null

Helper function that enables `repeat` to work with a `null` value.

_Introduced in DataWeave version 2.4.0._
