Skip to content

String TrimSuffix

The string::trimsuffix function removes a specified suffix from a string, if it exists.

Syntax

string::trimsuffix(<string>, <suffix>)

Parameters

  • string: The input string.
  • suffix: The suffix to remove.

Returns

  • String: A new string without the specified suffix. If the suffix is not found, the original string is returned.

Example

Try it out below!
string::trimsuffix("hello world", " world")

This function is useful for removing known suffixes from strings without manually checking for their presence.