@tempots/std

splitStringOnLast() function

Splits a string into two parts at the last occurrence of a specified substring. If the substring is found, the function returns an array with two elements: the part of the string before the substring and the part after the substring. If the substring is not found, the function returns an array with a single element, which is the original string.

Signature:

splitStringOnLast: (s: string, find: string) => [string] | [string, string]

Parameters

Parameter

Type

Description

s

string

The string to split.

find

string

The substring to search for.

Returns: [string] | [string, string]

An array containing the split parts of the string.