PADSTRING
Last updated
Was this helpful?
Last updated
Was this helpful?
The function PADSTRING extends the length of a string by repeating another string either at the beginning or end of the original string.
This function "pads" a base by appending a padding string repeated as many times as necessary to produce a string with the desired length. If the given string is longer than the length, the original string is returned unchanged. An optional fourth argument configures if the padding is added at the beginning ("LEFT"), or at the end ("RIGHT") of the base string.
base_string (type: string) The base string to pad.
pad_string (type: number) The string to use for padding.
length (type: number) The minimum length of the resulting string.
alignment (type: string) The direction to pad the string, "RIGHT" is the default and will append the padding to base_string, while "LEFT" will prepend the padding to base_string.
padded_string (type: string) A string that is at least length long produced by repeating pad_string at either the beginning or end of base_string.
A common use case for the function PADSTRING is to ensure that each item in a list is the same length to aid browsing the list by eye.
Notice that with a base_string that is longer than the minimum length it is returned with no changes.
By combining PADSTRING with the and functions, one can create a String that anonymizes sensitive information such as a credit card number, or social security number. When using PADSTRING in this way, be sure to do so in a using a . For the next example, assume that a variable named cc_number contains the credit card number 4111111111111111.