Skip to main content
trimsuffix(str, suffix) returns str with the trailing suffix removed. If str does not end with suffix, it is returned unchanged.

Signature

Example

Strip the trailing slash from a base URL variable so paths can be constructed consistently with a single slash separator:
https://api.example.com/ becomes https://api.example.com.

Notes

  • Only the suffix at the end is removed. If the string ends with the suffix more than once, only one occurrence is removed.
  • trimsuffix removes a literal string match, not individual characters. Use trim for character-set stripping.