Wolfram Language & System 10.4 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

StringPadLeft

StringPadLeft["string",n]
makes string be of length n, padding it on the left with spaces or truncating it if necessary.

StringPadLeft["string",n,"padding"]
pads by repeating copies of the string padding.

StringPadLeft[{"s1","s2",}]
pads strings with spaces on the left to make them all the same length.

StringPadLeft[{"s1","s2",},n,]
pads or truncates to make all strings of length n.

DetailsDetails

  • StringPadLeft effectively places repeated copies of padding to the left of string, truncating them when a total width of n characters has been achieved.

ExamplesExamplesopen allclose all

Basic Examples  (4)Basic Examples  (4)

Pad a string with whitespace to have total length 10:

In[1]:=
Click for copyable input
Out[1]=

Pad with a non-whitespace character:

In[1]:=
Click for copyable input
Out[1]=

Make a list of strings the same length:

In[1]:=
Click for copyable input
Out[1]=

Pad or truncate a list of strings to a given length:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2015
(10.1)