padleft()

Pads a string with a specified character or string on the left until it reaches the desired length.

Syntax

padleft(string, pad, length);

Parameters

Parameter Type Description Comment
string String The original string to be padded.
pad String The padding character or string. Defaults to “ ” (space) if empty.
length Number The desired total length of the output string. Maximum is 1000.

Return Value

Examples

Pad “abc” with spaces to a length of 10

padleft("abc", " ", 10); // returns "       abc"

Pad “123” with “0” to a length of 6

padleft("123", "0", 6); // returns "000123"

Pad “test” with “-” to a length of 8

padleft("test", "-", 8); // returns "----test"

See also

str
strlen
padleft
padright
hex
bin
chr
match