node-lib

@wtasnorg/node-lib


@wtasnorg/node-lib / cutPrefixString

Function: cutPrefixString()

cutPrefixString(s, prefix): object

Defined in: src/strings.ts:284

CutPrefix returns s without the provided leading prefix string and reports whether it found the prefix.

Parameters

s

string

Input string.

prefix

string

Prefix to remove.

Returns

object

after

after: string

found

found: boolean

Example

cutPrefix("Gopher", "Go"); // { after: "pher", found: true }
cutPrefix("Gopher", "X");  // { after: "Gopher", found: false }
cutPrefix("ab", "abc");    // { after: "ab", found: false } — prefix longer than s