I wonder if there are any alternatives to the Python rjust or zfill in DolphinDB.
I want to add zeros(0) on the specified side of a string until it reaches the specified length. How could I do?
I wonder if there are any alternatives to the Python rjust or zfill in DolphinDB.
I want to add zeros(0) on the specified side of a string until it reaches the specified length. How could I do?
For string
lpad(`Hello, 12, `0);
0000000Hello
rpad(`Hello, 12, `0);
Hello0000000
For decimal
decimalFormat(123,"00000");
00123
You can use function lpad and rpad to pad a string with a specific set of characters.
Take lpad for example,
s = "123"
s = lpad(s, 5, "0")
The result is '00123'.