padLeft

padLeft, function

def const pure padLeft(source: text, pad: text, size: number): text

Prepends pad to source until the result length is at least size. If size is less than the length of source, no padding is applied.

Example

table T = with
  [| as Source, as Pad, as Size |]
  [| "1234", "0",   7 |]
  [| "1234", "0_",  7 |]
  [| "1234", "0__", 7 |]
  [| "1234", "0__", 3 |]

T.Result = padLeft(T.Source, T.Pad, T.Size)

show table "Padded text" with
  T.Source
  T.Pad
  T.Size
  T.Result

This outputs the following table:

Source Pad Size Result
1234 0 7 0001234
1234 0_ 7 0_0_1234
1234 0__ 7 0__1234
1234 0__ 3 1234
User Contributed Notes
0 notes + add a note