---
schema_version: "1"
id: 1016e850f133110c8ba3b70f3877649b8dc78814ad0c9884d48e41ce6c61e4de
title: wrapIfMissing
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.3/dw-strings-functions-wrapifmissing.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.3/dw-strings-functions-wrapifmissing
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 794a2e2723baee4d825fefc6dcd778ada91975cfb5c567db4611f5bbed47ad86
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
# wrapIfMissing

## [](#wrapifmissing1)wrapIfMissing(String, String): String

指定された文字列の先頭または末尾から ​`wrapper`​ が欠落している場合、​`text`​ を ​`wrapper`​ でラップします。

_DataWeave 2.2.0 で導入されました。Mule 4.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>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>wrapper</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ラップするために使用するコンテンツ。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

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

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

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

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

```JSON
{
   "a": null,
   "b": "'",
   "c": "xabx",
   "d": "'ab'",
   "e": "/",
   "f": "/a/b/c/",
   "g": "/a/b/c/",
   "h": "/a/b/c/"
 }
```

## [](#wrapifmissing2)wrapIfMissing(Null, String): Null

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