Text.pad
padlengthwith_padat
Group: Calculations
Documentation
Returns the input padded to the specified length
, using the with_pad
string repeated at the start or the end.
Arguments
length
: The new length for the output. The result is the original string if the input length is more than length.with_pad
: The string to use to pad the input. If the last repetition exceeds the target length, it is truncated to the required size. If padding at theEnd
, the beginning of the padding string is used and if padding atStart
, the end of the string is used.at
: The location of where to pad the input.
Examples
Padding a text with whitespace at the end.
"Hello World!".pad 15 == "Hello World! "
Behavior of padding if the with_pad
string has to be truncated.
"HELLO".pad 9 "AB" == "HELLOABAB"
"HELLO".pad 8 "AB" == "HELLOABA"
"HELLO".pad 8 "AB" ..Left == "BABHELLO"