strip
is recommended over
strtrim
because it provides greater flexibility and
allows vectorization. For additional information, see
Alternative Functionality
.
newStr = strtrim(
str
)
removes
leading and trailing whitespace characters from
str
and returns
the result as
newStr
. However,
strtrim
does
not remove significant whitespace characters. For example,
strtrim
removes leading and trailing space and tab
characters, but does not remove the nonbreaking space character,
char(160)
.
str
—
Input text
character array
|
cell array of character arrays
|
string array
Input text, specified as a character array or as a cell array of character
arrays, or a string array.
Algorithms
strtrim
does not remove significant whitespace
characters.
This table shows the most common characters that are significant
whitespace characters and their descriptions. For more information, see
Whitespace
character
.
Significant Whitespace Character
Description
char(133)
Next line
char(160)
Nonbreaking space
char(8199)
Figure space
char(8239)
Narrow no-break space
Alternative Functionality
Update code that makes use of
strtrim
to use
strip
instead. For example:
Not Recommended
Recommended
str = " test ";
newStr = strtrim(str)
newStr =
"test"
str = " test ";
newStr = strip(str)
newStr =
"test"
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For
more information, see
Tall Arrays
.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Input text must be string scalar or a character array.
Input values must be in the range 0–127.
Generated code returns an empty output as a 1-by-0
character array.
Thread-Based Environment
Run code in the background using MATLAB®
backgroundPool
or accelerate code with Parallel Computing Toolbox™
ThreadPool
.