Skip to content

strtrunc

Truncate a string to a specified length.

s = strtrunc(str, n)

Returns the first n characters of str. If str has fewer than n characters, the original is returned unchanged.

strtrunc('hello world', 5) % 'hello'
  • deblank — Remove trailing whitespace from a string.
  • strtrim — Remove leading and trailing whitespace from a string.