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

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