Pads a string at the end to a specified length.
pad_end(x:string, length:int, [pad_char:string]) -> string
Description
Section titled “Description”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.
x: string
Section titled “x: string”The string to pad.
length: int
Section titled “length: int”The target length of the resulting string.
pad_char: string
Section titled “pad_char: string”The character to use for padding. Must be a single character. Defaults to a space.
Defaults to " "
.
Examples
Section titled “Examples”Pad with spaces
Section titled “Pad with spaces”from {x: "hello".pad_end(10)}
{x: "hello "}
Pad with custom character
Section titled “Pad with custom character”from {x: "hello".pad_end(10, ".")}
{x: "hello....."}
String already long enough
Section titled “String already long enough”from {x: "hello world".pad_end(5)}
{x: "hello world"}