---
schema_version: "1"
id: 082161e344e7eba38acf562a5845d1e672a06ec4c71acf827df23e18b8590959
title: trim
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.7/dw-core-functions-trim.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.7/dw-core-functions-trim
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a1d641739cf914517fccf6811662dec9c7f0cded93ad5b8f261c883498b43055
description: MuleSoft Documentation Site
release: "2.7"
latest: false
---
# trim

## [](#trim1)trim(text: String): String

文字列の先頭と末尾に空白スペースがあれば、それを削除します。

### [](#パラメーター)パラメーター

<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>
</tbody>
</table>

### [](#例)例

この例では、文字列の先頭と末尾の空白を削除します。文字列の中間にある空白スペースは削除されません。削除されるのは、先頭と末尾の空白スペースのみです。

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

```DataWeave
%dw 2.0
output application/json
---
{ "trim": trim("   my really long  text     ") }
```

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

```JSON
{ "trim": "my really long  text" }
```

### [](#例-2)例

次の例では、​`trim`​ がさまざまな文字列をどのように処理するかと、null 値をどのように処理するかを示します。

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

```DataWeave
%dw 2.0
output application/json
---
{
  "null": trim(null),
  "empty": trim(""),
  "blank": trim("     "),
  "noBlankSpaces": trim("abc"),
  "withSpaces": trim("    abc    ")
}
```

#### [](#出力-2)出力

```JSON
{
  "null": null,
  "empty": "",
  "blank": "",
  "noBlankSpaces": "abc",
  "withSpaces": "abc"
}
```

## [](#trim2)trim(value: Null): Null

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