Add leading or trailing characters to strings
adds space
characters to the ends of the strings in newStr
= pad(str
)str
, except for the
longest one.
If str
is a string array or cell array of character
vectors with multiple elements, then pad
adds space
characters. All of the strings in newStr
are as long as
the longest element in str
.
If str
is a character vector, or a string array or cell
array of character vectors with one element, then pad
returns str
unaltered.
adds space characters so the strings in newStr
= pad(str
,numberOfCharacters
)newStr
have the length
specified by numberOfCharacters
. If any strings in
str
have more characters than
numberOfCharacters
, then pad
does not
modify them.
adds space characters to the side specified by newStr
= pad(str
,numberOfCharacters
,side
)side
, up to the
length specified by numberOfCharacters
.
pads strings with the character specified by newStr
= pad(___,padCharacter
)padCharacter
instead
of the space character. You can use any of the input arguments in the previous
syntaxes.
If str
contains only one piece of text, then pad(str,padCharacter)
returns str
unaltered.