Main Content

strtrim

Remove leading and trailing white space from string

Since R2021b

Description

example

newStr = strtrim(str) removes the leading and trailing whitespace characters from the string str.

Note

The strtrim operator is not supported in Stateflow® charts that use C as the action language.

Examples

expand all

Remove the leading and trailing spaces and return the string "Hello, world!"

str = "    Hello, world!   ";
newStr = strtrim(str);

Stateflow chart that uses the strtrim operator in a state.

Input Arguments

expand all

Input string, specified as a string scalar. Enclose literal strings with double quotes.

Example: "Hello"

Limitations

Version History

Introduced in R2021b