Text.Trim
---------

Trims whitespace on the left and right side.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Text](component_Text.md) | [8.2](newinversion82.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Text.Trim"; Text ) 

**MBS**( **"Text.Trim";** /\* Trims whitespace on the left and right side. \*/  
**$Text**) /\* The text to trim.e.g. " Hello " \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Text | The text to trim. | " Hello " |

### Result

Returns text or error.

### Description

Trims whitespace on the left and right side.  
May remove low ASCII characters like tab, CR, LF and space.  
Also removes alt-space and delete character.  
  
This function works on pure text, so any text style is lost.  
### Examples

Trim hello:

 MBS ( "Text.Trim"; " ¶ Hello ¶ ")  
<small>  
Example result: Hello</small>Trim emojis:

 MBS ( "Text.Trim"; " 🍎 🍓 🍒 ")  
<small>  
Example result: 🍎 🍓 🍒</small>Remove some invisble characters:

 Substitute("Hello";   
\[Char(173);""\]; // 00AD soft hyphen  
\[Char(8203);""\]; // 200B zero width space  
\[Char(8204);""\]; // 200C zero width non-joiner  
\[Char(8205);""\]; // 200D zero width joiner  
\[Char(8239);" "\]; // 202F narrow no-break space  
\[Char(8287);" "\]; // 205F medium mathematical space  
\[Char(8288);""\]; // 2060 word joiner  
\[Char(8289);""\]; // 2061 function application  
\[Char(8290);""\]; // 2061 invisible times  
\[Char(8291);""\]; // 2062 invisible separator  
\[Char(8292);""\]; // 2063 invisible plus  
\[Char(65279);""\] // FEFF zero width space  
)  
### Release notes

- **Version 8.2**
    - Added [Text.Trim](http://www.mbsplugins.eu/TextTrim.shtml) function.

### Example Databases

- [List/Sort Benchmark](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/List/Sort%20Benchmark.shtml#1ScriptAnchor_)
- [Mac and iOS/PDFKit/PDF Merge Shrink Tool](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/PDFKit/PDF%20Merge%20Shrink%20Tool.shtml#16ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 8.2pr5](https://www.mbsplugins.de/archive/2018-05-02/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin Schulung in 2018](https://www.mbsplugins.de/archive/2018-05-02/MBS_FileMaker_Plugin_Schulung_/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 30th April 2018 , last changed 10th May 2024

  
[Text.TidyErrorLog](TextTidyErrorLog.md) - [Text.UpperCase](TextUpperCase.md)

[HTML Version](TextTrim.shtml)