@tempots/std

splitStringOnFirst() function

Splits a string into two parts based on the first occurrence of a specified substring. If the substring is found, 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, returns an array with a single element: the original string.

Signature:

splitStringOnFirst: (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.