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.
trimsuffixremoves a literal string match, not individual characters. Usetrimfor character-set stripping.