Skip to content

strtrim

Remove leading and trailing whitespace from a string.

s = strtrim(str)

Strips both leading and trailing whitespace from str. Internal whitespace is preserved. Applied elementwise to cell arrays of strings.

strtrim(' hello ') % 'hello'
  • deblank — Remove trailing whitespace from a string.
  • strtrunc — Truncate a string to a specified length.