---
schema_version: "1"
id: 95a948437a7760daaec24b0f93026ee8f94beb2ac4283bdb8f3ff4e265393324
title: substringEvery
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-strings-functions-substringevery.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-strings-functions-substringevery
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9c20fa5f1398e2150dd3fa893bafc0a70b6c052755a78dc5c4504b61f4a0ed01
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

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