<div class="meta" robots="noindex">

</div>

Method

# Trim

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `String.Trim<string.trim>` as a replacement.

</div>

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Returns the `string</api/data_types/string>` passed with leading and trailing whitespaces removed.

## Usage

``` xojo
result = Trim(sourceString)
```

OR

``` xojo
result = stringVariable.Trim
```

| Part           | Type                             | Description                                                                                |
|----------------|----------------------------------|--------------------------------------------------------------------------------------------|
| result         | `String</api/data_types/string>` | *SourceString* with leading and trailing whitespaces removed.                              |
| sourceString   | `String</api/data_types/string>` | The source, a copy of which, to be returned with leading and trailing whitespaces removed. |
| stringVariable | `String</api/data_types/string>` | Any variable of type `String</api/data_types/string>`.                                     |

## Notes

Trim uses [this list](http://www.unicode.org/Public/UNIDATA/PropList.txt) of unicode "whitespace" characters.

## Sample code

This example removes the whitespaces from either side of the string passed:

``` xojo
Var s As String
s = Trim("  Hello World  ") ' Returns "Hello World"
s = "    Hello World   "
s = s.Trim ' Returns "Hello World"
```

## Compatibility

All project types on all supported operating systems.

## See also

`Asc</api/math/asc>`, `Chr</api/text/chr>`, `String.IndexOf<string.indexof>`, `String.Left<string.left>`, `String.Length<string.length>`, `String.TrimLeft<string.trimleft>`, `String.Middle<string.middle>`, `String.Right<string.right>`, `String.TrimRight<string.trimright>` functions.
