Skip to content
Legacy docs for Tenzir v5.x. For the latest Tenzir v6 series, visit docs.tenzir.com. Migrating from v5? Read the Tenzir v6 migration guide.

Trims whitespace or specified characters from both ends of a string.

trim(x:string, [chars:string]) -> string

The trim function removes characters from both ends of x.

When called with one argument, it removes leading and trailing whitespace. When called with two arguments, it removes any characters found in chars from both ends of the string.

The string to trim.

A string where each character represents a character to remove. Any character found in this string will be trimmed from both ends.

Defaults to whitespace characters.

from {x: " hello ".trim()}
{x: "hello"}
from {x: "/path/to/file/".trim("/")}
{x: "path/to/file"}
from {x: "--hello--world--".trim("-")}
{x: "hello--world"}

Last updated: