Skip to content

pad_end

Pads a string at the end to a specified length.

pad_end(x:string, length:int, [pad_char:string]) -> string

The pad_end function pads the string x at the end with pad_char (default: space) until it reaches the specified length. If the string is already longer than or equal to the specified length, it returns the original string unchanged.

The string to pad.

The target length of the resulting string.

The character to use for padding. Must be a single character. Defaults to a space.

Defaults to " ".

from {x: "hello".pad_end(10)}
{x: "hello "}
from {x: "hello".pad_end(10, ".")}
{x: "hello....."}
from {x: "hello world".pad_end(5)}
{x: "hello world"}

pad_start, trim, trim_end

Last updated: