HomeManualTopicsTypesSymbols

std::pad_left

extends a string to the specified width

Parameters

expr
the expression that is converted into a string
n
the length of the resulting string
pad (default: " ")
the pattern used to fill up the string

Results

None

Description

This function creates a string representation of expr which is at least n characters long. If it would be shorter than it is padded to the left with the string pattern stored in pad.

The default value for pad is a single space.

Example

$str "123" $padded_str pad_left(str 5 "0") println! padded_str

Output

00123

Topic

Strings

See also

std::pad_right extends a string to the specified width