string.trimSuffix

This function returns the input string without the specified trailing suffix string. If it does not end with a suffix, it is returned unchanged.

Syntax

string.trimSuffix(str, suffix)

Arguments

Argument

Type

Description

str

string

Source string

suffix

string

Trailing suffix string

Returns

Type

Description

string

  • Input string without the specified trailing suffix string.
  • If the input string does not end with the specified suffix, it is returned unchanged.

Examples

  • The function string.trimSuffix("Hello World", "World") returns Hello.
  • The function string.trimSuffix("¡¡¡Hello, Gophers!!!", ", Gophers!!!") returns ¡¡¡Hello.