---
schema_version: "1"
id: 77bee596b75078f7c0d379515a187c6dc3f4a20773bf3c5653464c8f27d80e79
title: trim()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_saql/guides/reference/bi-saql-functions-string-trim.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-string-trim.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: d8f1ce4b4d91dc26ae5ff7b4d7485197c37155118cf216980c1dc133369fc129
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# trim()

Removes the specified substring from the beginning and the end of a string.

## Syntax

`trim`(_string_,_substr_)

## Usage

This function removes _substr_ from the beginning and end of _string_, then returns the result. To remove leading and trailing spaces, do not specify a value for _substr_.

## Example

```nolang
–-  the resulting string in both cases is 'MyString';
q = foreach q generate trim("abcMyStringabc","abc") as 'Trimmed String';
q = foreach q generate trim("     MyString     ") as 'Trimmed String';
```
