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

# 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._
