---
schema_version: "1"
id: bd782541e34b6d076f53b8005b7d07ce513729144dd24045835b9dc55602e67b
title: find
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.4/dw-core-functions-find.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.4/dw-core-functions-find
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2697f8a8ad82d4e61b36b91f5ebcebdc2500fddc7cb0913d8e673743020a41af
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
# find

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

指定された値と一致する、入力のインデックスを返します。

このバージョンの関数は、配列のインデックスを返します。その他のバージョンは、文字列のインデックスを返します。

### [](#パラメーター)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>elements</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">任意のデータ型の要素を含む配列。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>elementToFind</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">入力配列内で検索する値。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、文字列配列内の要素のインデックスを検索します。

#### [](#ソース)ソース

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

#### [](#出力)出力

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

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

指定された正規表現 (regex) および後続のキャプチャグループと一致する、テキスト内のインデックスを返します。

結果のサブ文字列内の最初の要素は、regex と一致したテキスト内のインデックス、次の要素は、regex 内のキャプチャグループです (存在する場合)。

注意: テキストのうち、regex と一致する部分を取得するには、​`scan`​ 関数を使用します。

### [](#パラメーター-2)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>text</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">文字列。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>matcher</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>text</code>​ 内の文字を照合する Java 正規表現。</p></td>
</tr>
</tbody>
</table>

### [](#例-2)例

次の例では、​`ea`​ が含まれる語の開始インデックスと終了インデックスを検索します。

#### [](#ソース-2)ソース

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

#### [](#出力-2)出力

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

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

文字列の指定された文字が存在する位置のインデックスをリストします。

### [](#パラメーター-3)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>text</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ソース文字列。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>textToFind</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ソース文字列で検索する文字列。</p></td>
</tr>
</tbody>
</table>

### [](#例-3)例

次の例では、「aabccdbce」内にある「a」のインデックスをリストします。

#### [](#ソース-3)ソース

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

#### [](#出力-3)出力

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

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

`find`​ を ​`null`​ 値に使用できるようにするヘルパー関数。