trim

string

Removes whitespace from both ends of a string

Syntax

trim(string)

Parameters

string (string)

The string to trim

Returns

string

String with leading and trailing whitespace removed

Examples

Input:
trim("  hello  ")
Output:
"hello"
Input:
trim("  test")
Output:
"test"
Input:
"  world  " | trim
Output:
"world"

The trim() function removes whitespace (spaces, tabs, newlines) from both the beginning and end of a string.

Usage

Use trim() to clean user input, normalize data, or remove unwanted whitespace from text fields. Essential for data cleaning and standardization.

Related Functions