strip
Remove leading and trailing characters from text.
📝Syntax
res = strip(str)
res = strip(str, side)
res = strip(str, side, stripCharacter)
📥Input Arguments
Parameter Description
str character array, string scalar, string array, or cell array of character vectors.
side optional side selector: leading, trailing, left, right, or both when supported.
stripCharacter optional character to remove instead of whitespace.
📤Output Arguments
Parameter Description
res text with selected leading or trailing characters removed.
📄Description

strip removes leading and trailing whitespace from text by default.

Optional arguments can select a side and the character to remove when supported by the string module.

💡Examples
Remove leading and trailing whitespace from a string.
txt = strip("  Nel Son  ")
🔗See Also
strtrimdeblanklowerupper
Used Functions
strtrim
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub