Skip to main content

core.splitn

Home > @medplum/core > splitN

splitN() function

Splits a string into an array of strings using the specified delimiter. Unlike the built-in split function, this function will split the string into a maximum of exactly n parts. Trailing empty strings are included in the result.

Signature:

export declare function splitN(str: string, delim: string, n: number): string[];

Parameters

ParameterTypeDescription
strstringThe string to split.
delimstringThe delimiter.
nnumberThe maximum number of parts to split the string into.

Returns:

string[]

The resulting array of strings.