padright()

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

Syntax

padright(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

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

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

padright("123", "0", 6); // returns "123000"

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

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

See also

str
strlen
padleft
padright
hex
bin
chr
match