Skip to content

Function.removePrefix

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

umt / removePrefix

Function: removePrefix()

removePrefix(string_, prefix): string

Defined in: String/removePrefix.ts:12

Removes the given prefix from the start of a string once, if present. Unlike trimStartCharacters, which removes any of a set of characters repeatedly, this removes the exact prefix a single time.

Parameters

string_

string

Input string

prefix

string

Prefix to remove

Returns

string

String without the leading prefix

Example

removePrefix("https://example.com", "https://"); // "example.com"
removePrefix("example.com", "https://"); // "example.com"

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally