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

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