---
schema_version: "1"
id: 32b22b71ecf4c12d74dfffdfa1fbea41350280f5121ff85653e1c04cbd5b5d39
title: trim
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.4/dw-core-functions-trim.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.4/dw-core-functions-trim
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2a8f81855a552aa290d3e8069439aeb1856f2eeccbec3087dccbfedbda5100e8
description: MuleSoft Documentation Site
release: "2.4"
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`​ 値に使用できるようにするヘルパー関数。