# trim in JS

{% hint style="info" %}
**Important Notice: Migration of Documentation Website**

Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:

[Official Snowflake Snowconvert Documentation](https://docs.snowflake.com/en/migrations/snowconvert-docs/translation-references/transact/README)

For any immediate assistance or if you encounter any issues, please contact our support team at [snowconvert-support@snowflake.com](mailto:snowconvert-support@snowflake.com).

Thank you for your understanding.
{% endhint %}

<details>

<summary>Applies to</summary>

* [x] SQL Server
* [x] Azure Synapse Analytics

</details>

## Description

Replaces the occurrences of a pattern using a new one sent as a parameter ([JavaScript Replace function Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)).

## Sample Source Pattern

### Syntax

```javascript
String.trim( )
```

#### Arguments

This function does not receive any parameters.

#### Return Type

String.

## Examples

{% tabs %}
{% tab title="Query" %}
```sql
CREATE OR REPLACE FUNCTION TRIM_STR(str varchar)
  RETURNS string
  LANGUAGE JAVASCRIPT
AS
$$
   return STR.trim( );
$$;

SELECT TRIM_STR('  FIRST AND LAST TWO BLANK SPACES  ')TRIM
```
{% endtab %}

{% tab title="Result" %}
```
                           TRIM|      
-------------------------------+
FIRST AND LAST TWO BLANK SPACES|   
```
{% endtab %}
{% endtabs %}

## Known Issues <a href="#known-issues" id="known-issues"></a>

No issues were found.

## Related EWIs <a href="#related-ewis" id="related-ewis"></a>

No related EWIs.
