lpad

To fill up a given length with given padding at the beginning

With this function, you fill a text at the beginning, i.e. to the left of the text, with one or more given characters up to the desired total length. The given characters are repeated until the given total length is reached.

This can be very useful when - for technical reasons - data must have a certain length, or for optical padding in print layouts in a non-proportional font.

If the source text already reaches or exceeds the specified length, it remains unchanged.

Syntax

lpad(string, number, string)

Return

string

Examples

lpad(myText, length, padding) To fill up a given length with given padding at the beginning, if the given text is shorter than the given length.

lpad("A text", 20, "+ ")

Result: + + + + + + + A text

lpad(text(123), 8, "0")

Result: 00000123

See also

rpad, which fills up a given length with given padding at the end.

Last updated