Skip to content

StringPadRight

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

StringPadRight["string", n]
    Makes "string" length n, padding on the right with spaces or
    truncating (keeping the first n characters) as needed.
StringPadRight["string", n, "padding"]
    Pads with repeated copies of "padding".
StringPadRight[{s1, s2, ...}]
    Pads each string on the right with spaces to the length of the
    longest, making them all the same length.
StringPadRight[{s1, s2, ...}, n, ...]
    Pads or truncates each string to length n.

Examples

All examples below are verified against the current Mathilda build.

In[1]:= StringPadLeft["abcde", 10]
Out[1]= "     abcde"

In[2]:= StringPadRight["abcde", 10, "."]
Out[2]= "abcde....."

In[3]:= StringPadLeft[{"a", "ab", "abc", "abcd", "abcde"}]
Out[3]= {"    a", "   ab", "  abc", " abcd", "abcde"}

In[4]:= StringPadLeft[{"a", "ab", "abc", "abcd", "abcde"}, 3]
Out[4]= {"  a", " ab", "abc", "bcd", "cde"}

Implementation notes

Attributes: Protected.

Implementation status

Stable — documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

References