---
schema_version: "1"
id: 0cf77b67dcd9209d54ee6e19ce92adcb330ba0fd6a82c410ba8cb7f1f357c486
title: substringBefore
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.8/dw-strings-functions-substringbefore.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.8/dw-strings-functions-substringbefore
source_site: docs.mulesoft.com
content_type: documentation
content_hash: e6249508dd1fc4728b27b54772a2e2b1dbb01b98a3e993f6de7f7a584256fb37
description: MuleSoft Documentation Site
release: "2.8"
latest: false
---
# substringBefore

## [](#substringbefore1)substringBefore(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>

### [](#例)例

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

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

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

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

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

## [](#substringbefore2)substringBefore(text: Null, separator: String): Null

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

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