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

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