---
schema_version: "1"
id: 87a199424d84c5a2ad16226247ed2636a1b7c4ebfd889094689802814f4a4ac7
title: find
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-core-functions-find.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-core-functions-find
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 0d0afb8e26de441229970a11e3b45b3f806024b00631ec72689b9fccbf524157
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# find

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

## find<T>(@StreamCapable() elements: Array<T>, elementToFind: Any): Array<Number>

Returns indices of an input that match a specified value.

This version of the function returns indices of an array. Others return indices of a string.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>elements</code></p></td><td><p>An array with elements of any type.</p></td></tr><tr><td><p><code>elementToFind</code></p></td><td><p>Value to find in the input array.</p></td></tr></tbody></table>

### Example

This example finds the index of an element in a string array.

#### Source

```DataWeave
%dw 2.0
output application/json
---
["Bond", "James", "Bond"] find "Bond"
```

#### Output

```JSON
[0,2]
```

## find(@StreamCapable() text: String, matcher: Regex): Array<Array<Number>>

Returns the indices in the text that match the specified regular expression (regex), followed by the
capture groups.

The first element in each resulting sub-array is the index in the text that matches the regex, and
the next ones are the capture groups in the regex (if present).

Note: To retrieve parts of the text that match a regex. use the `scan` function.

### 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>A string.</p></td></tr><tr><td><p><code>matcher</code></p></td><td><p>A Java regular expression for matching characters in the <code>text</code>.</p></td></tr></tbody></table>

### Example

This example finds the beginning and ending indices of words that contain `ea`

#### Source

```DataWeave
%dw 2.0
output application/json
---
"I heart DataWeave" find /\w*ea\w*(\b)/
```

#### Output

```JSON
[ [2,7], [8,17] ]
```

## find(@StreamCapable() text: String, textToFind: String): Array<Number>

Lists indices where the specified characters of a string are present.

### 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>A source string.</p></td></tr><tr><td><p><code>textToFind</code></p></td><td><p>The string to find in the source string.</p></td></tr></tbody></table>

### Example

This example lists the indices of "a" found in "aabccdbce".

#### Source

```DataWeave
%dw 2.0
output application/json
---
"aabccdbce" find "a"
```

#### Output

```JSON
[0,1]
```

## find(@StreamCapable() text: Null, textToFind: Any): Array<Nothing>

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