---
schema_version: "1"
id: 2bbcbcaa1a53f64e7b2dadc18d59618fbe2497e85704958b4288cd90f9d7cfd5
title: prependIfMissing
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.6/dw-strings-functions-prependifmissing.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.6/dw-strings-functions-prependifmissing
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 3b454ec65a82b2826251e7871dcf8471a77a82ff59adf213591b629d6c73a2a4
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
# prependIfMissing

## [](#prependifmissing1)prependIfMissing(text: String, prefix: String): String

`text`​ が ​`prefix`​ で開始されていない場合、文字列の先頭にそのプレフィックスを追加します。

_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>prefix</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">プレフィックスとして使用するテキスト。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

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

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

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

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

```JSON
{
  "a": null,
  "b": "abc",
  "c": "xyz",
  "d": "xyzabc",
  "e": "xyzabc"
}
```

## [](#prependifmissing2)prependIfMissing(text: Null, prefix: String): Null

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

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