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

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