Skip to content

trim_end

Trims whitespace or specified characters from the end of a string.

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

The trim_end function removes characters from the end of x.

When called with one argument, it removes trailing whitespace. When called with two arguments, it removes any characters found in chars from the end 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 the end.

Defaults to whitespace characters.

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

trim, trim_start

Last updated: