---
schema_version: "1"
id: 36466fd110e74740f7f56122667dc518a15786d07e6b3b3106c6031e2967eef6
title: indexOf
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.6/dw-core-functions-indexof.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.6/dw-core-functions-indexof
source_site: docs.mulesoft.com
content_type: documentation
content_hash: aad49c9fdf8a849993f289a4c47e5e0491f078495d334c97b4b9021a954941ae
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
# indexOf

## [](#indexof1)indexOf(array: Array, value: Any): Number

この配列の指定された要素の​_最初_​の出現のインデックスを返し、このリストに要素が含まれていない場合は ​`-1`​ を返します。

_DataWeave バージョン 2.4.0 で導入されました。_

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

<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>array</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>value</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">検索する値。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、さまざまな入力での ​`indexOf`​ の動作を示します。

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

```DataWeave
%dw 2.0
output application/json
---
{
  present: ["a","b","c","d"] indexOf "c",
  notPresent: ["x","w","x"] indexOf "c",
  presentMoreThanOnce: ["a","b","c","c"] indexOf "c",
}
```

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

```Json
{
   "present": 2,
   "notPresent": -1,
   "presentMoreThanOnce": 2
 }
```

## [](#indexof2)indexOf(theString: String, search: String): Number

この文字列の指定された文字列の​**最初**​の出現のインデックスを返します。

_DataWeave バージョン 2.4.0 で導入されました。_

### [](#パラメーター-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>theString</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>search</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>theString</code>​ 内で検索する文字列。</p></td>
</tr>
</tbody>
</table>

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

次の例では、さまざまな入力での ​`indexOf`​ の動作を示します。

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

```DataWeave
%dw 2.0
output application/json
---
{
  present: "abcd" indexOf "c",
  notPresent: "xyz" indexOf "c",
  presentMoreThanOnce: "abcdc" indexOf "c",
}
```

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

```Json
{
   "present": 2,
   "notPresent": -1,
   "presentMoreThanOnce": 2
 }
```

## [](#indexof3)indexOf(array: Null, value: Any): Number

indexOf を null 対応にするためのヘルパーメソッド。

_DataWeave バージョン 2.4.0 で導入されました。_