Skip to content

Function.removeSuffix

github-actions[bot] edited this page Jun 20, 2026 · 21 revisions

umt / removeSuffix

Function: removeSuffix()

removeSuffix(string_, suffix): string

Defined in: String/removeSuffix.ts:12

Removes the given suffix from the end of a string once, if present. Unlike trimEndCharacters, which removes any of a set of characters repeatedly, this removes the exact suffix a single time.

Parameters

string_

string

Input string

suffix

string

Suffix to remove

Returns

string

String without the trailing suffix

Example

removeSuffix("file.txt", ".txt"); // "file"
removeSuffix("file", ".txt"); // "file"

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally