Skip to main content

$$pad

Pad a provided string with certain character(s) repeated until a certain width of output string

(Strings longer than width will be returned as-is)

Usage​

{ 
"$$pad": /* input */,
"direction": /* LEFT / START / RIGHT / END */,
"width": /* integer */,
"pad_string": "0" /* string */
}
"$$pad(<direction>,<width>,[pad_string]):{input}"
note

Concrete values in the usage example are default values.

Returns​

string

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryanynullValue to pad
directionenumLEFT/ START/RIGHT/ENDYesOn which side of the input to pad
widthintegerYesWhat is the maximum length of the output string
pad_stringstring"0"The character(s) to pad with

Examples​

Input

Definition

Output

"text"
"$$pad(END,6):text"
"text00"
"text"
"$$pad(RIGHT,6,0):$"
"text00"
"text"
"$$pad(END,6,' '):$"
"text  "
"text"
"$$pad(LEFT,6,' '):$"
"  text"
"text"
"$$pad(LEFT,6,x):$"
"xxtext"
"text"
"$$pad(RIGHT,3,2):$"
"text"
"text"
"$$pad(START,6,xy):$"
"xytext"
"text"
"$$pad(START,9,xy):$"
"xyxyxtext"
"text"
"$$pad:$"
"text"
"text"
"$$pad(START):$"
"text"