---
schema_version: "1"
id: 9ce6c07d499551ccca3fefa72ec022f83dcd02c32317e71a76f97e0f1f5ed2e7
title: find
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dw-core-functions-find.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dw-core-functions-find
source_site: docs.mulesoft.com
content_type: documentation
content_hash: c4115d21855e6f1a9427a81a007ff5060eaf5b465f1735965972ed97fb2c9cc8
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
---
product: DataWeave
version: 2.4
---

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