---
schema_version: "1"
id: b705882bbcf9b857ffe990bdc8bc89422c8ed479e582f3d79763291f2c362570
title: leftPad
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.4/dw-strings-functions-leftpad.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.4/dw-strings-functions-leftpad
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 075ce088d75a530df437aa94ba66b07b265a9d82019e75b8331b9304535896cc
description: MuleSoft Documentation Site
release: "2.4"
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 で導入されました。_​