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

## [](#lastindexof1)lastIndexOf(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"] lastIndexOf "c",
  notPresent: ["x","w","x"] lastIndexOf "c",
  presentMoreThanOnce: ["a","b","c","c"] lastIndexOf "c",
}
```

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

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

## [](#lastindexof2)lastIndexOf(array: String, value: String): Number

文字列を入力として取得し、入力内の特定の検索文字列の​_最後_​の出現のインデックスを返します。検索文字列が入力に存在しない場合、この関数では ​`-1`​ を返します。

_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>string</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>

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

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

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

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

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

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

## [](#lastindexof3)lastIndexOf(array: Null, value: Any): Number

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

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