Available in all subroutines.
Constructs a string containing the input string
s, padded out
pad to produce a string of the given
width. The padding string
is repeated as necessary, and cut short when
width is reached.
width is given in bytes, and this function will cut short paddings
with multi-byte encodings.
s by placing padding to the right. Positive
s by placing padding to the left. If
width is less
than or equal to the length of
s, then no padding is performed.
pad is the empty string, then no padding is performed, and the unmodified
s is returned.
set var.s = std.strpad("abc", -10, "-="); # produces "abc-=-=-=-"set var.s = std.strpad("abc", 10, "-="); # produces "-=-=-=-abc"
Repeating a string:
declare local var.s STRING;declare local var.n INTEGER;set var.n = std.strlen("abcd");set var.n *= 3;set var.s = std.strpad("", var.n, "abcd"); # repeat "abcd" three times
User contributed notes
We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.