string.trimPrefix

This function returns the input string without the provided leading prefix string. If the input string does not start with the prefix, it is returned unchanged.

Syntax

string.trimPrefix(str, prefix)

Arguments

Argument

Type

Description

str

string

Source string

prefix

string

Leading prefix string

Returns

Type

Description

string

  • String without the specified leading prefix string.
  • If the input string does not start with the prefix, it is returned unchanged.

Examples

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