Skip to content

pad_start

Pads a string at the start to a specified length.

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

The pad_start function pads the string x at the start 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_start(10)}
{x: " hello"}
from {x: "42".pad_start(5, "0")}
{x: "00042"}
from {x: "hello world".pad_start(5)}
{x: "hello world"}

pad_end, trim, trim_start

Last updated: