---
schema_version: "1"
id: bc2d396e9ff2642ba4d26973d531e8bd968c9c5d54bfa69c8764217e6a2a8bf6
title: substringBeforeLast
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.4/dw-strings-functions-substringbeforelast.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.4/dw-strings-functions-substringbeforelast
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2e7ad7094e6d5aa90c8be283d298b460fbcb0925d4b3040a7c6f8b686521fe3e
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
# substringBeforeLast

## [](#substringbeforelast1)substringBeforeLast(text: String, separator: String): String

区切り文字の最後の出現位置より前にあるサブ文字列を取得します。区切り文字は返されません。

_DataWeave バージョン 2.2.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>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>separator</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">検索対象の文字列。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、さまざまな入力とサイズでの ​`substringBeforeLast`​ の動作を示します。

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

```DataWeave
%dw 2.0
import * from dw::core::Strings
output application/json
---
{
  "a": substringBeforeLast(null, "'"),
  "b": substringBeforeLast("", "-"),
  "c": substringBeforeLast("abc", "b"),
  "d": substringBeforeLast("abcba", "b"),
  "e": substringBeforeLast("abc", "d"),
  "f": substringBeforeLast("abc", "")
}
```

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

```JSON
{
  "a": null,
  "b": "",
  "c": "a",
  "d": "abc",
  "e": "",
  "f": "ab"
}
```

## [](#substringbeforelast2)substringBeforeLast(text: Null, separator: String): Null

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

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