deblank
Remove trailing whitespace from ends of strings
Syntax
Description
Note
strip
is recommended over
deblank
because it provides greater flexibility and
allows vectorization. For additional information, see Alternative Functionality.
newStr = deblank(
removes
trailing whitespace and null characters from str
)str
and returns the
result as newStr
. However, deblank
does not
remove significant whitespace characters. For example, deblank
removes trailing space and tab characters, but does not remove the nonbreaking space
character, char(160)
.
Examples
Input Arguments
Algorithms
deblank
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 |
---|---|
| Next line |
| Nonbreaking space |
| Figure space |
| Narrow no-break space |
Alternative Functionality
Update code that makes use of deblank
to use strip
instead. Unlike deblank
, which only removes
whitespace characters from the end of text, strip
removes both
leading and trailing whitespace characters. To remove only trailing whitespace
characters using strip
, specify the "right"
option. For example:
Not Recommended | Recommended |
---|---|
str = " test ";
newStr = deblank(str) newStr = " test" |
str = " test "; newStr = strip(str,"right") newStr = " test" |
Extended Capabilities
Version History
Introduced before R2006a