---
schema_version: "1"
id: 01f267c66d1eb32f266efbbbe62a2f1b2d4f92928f896d67f8ebe456328ade20
title: leftPad
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.8/dw-strings-functions-leftpad.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.8/dw-strings-functions-leftpad
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 5b00af6a07ed4657d080eeb8cfc7d3ad14e8765273f7f93b415615330ad58eee
description: MuleSoft Documentation Site
release: "2.8"
latest: false
---
# leftPad

## [](#leftpad1)leftPad(text: String, size: Number, padText: String = " "): String

目的のサイズ (​`size`​) になるように、指定された ​`text`​ の​_左_​側に ​`padText`​ を埋め込みます。 デフォルトの ​`padText`​ は ​`" "`​ です。

左側をパディングした ​`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>size</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>padText</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">埋め込むテキスト。指定されていない場合、デフォルトで 1 桁の空白に設定されます。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

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

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

```DataWeave
%dw 2.0
import * from dw::core::Strings
output application/json
---
{
   "a": leftPad(null, 3),
   "b": leftPad("", 3),
   "c": leftPad("bat", 5),
   "d": leftPad("bat", 3),
   "e": leftPad("bat", -1)
}
```

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

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

## [](#leftpad2)leftPad(text: Null, size: Any, padText: Any = " "): Null

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

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