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

# substringEvery

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

## substringEvery(text: String, amount: Number): Array<String>

Splits a string into an array of substrings equal to a specified length.

The last substring can be shorter than that length. If the length is greater than or equal to the
length of the string to split, the function returns the entire string.

_Introduced in DataWeave version 2.4.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 string to split.</p></td></tr><tr><td><p><code>amount</code></p></td><td><p>The desired length of each substring.</p></td></tr></tbody></table>

### Example

This example shows how `substringEvery` behaves when splitting an input string. The last returned
substring is shorter than the others.

#### Source

```DataWeave
%dw 2.0
import substringEvery from dw::core::Strings
output application/json
---
substringEvery("substringEvery", 3)
```

#### Output

```Json
["sub", "str", "ing", "Eve", "ry"]
```

## substringEvery(text: Null, amount: Any): Null

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

_Introduced in DataWeave version 2.4.0._
