platform-bible-utils
    Preparing search index...

    Function split

    • This function mirrors the split function from the JavaScript Standard String object. It operates on grapheme clusters instead of UTF-16 code units.

      Divides the string into an ordered list of substrings by searching for a pattern, and returns them as an array.

      Parameters

      • string: string

        The string to split

      • separator: string | RegExp

        The pattern describing where each split should occur. An empty string splits into individual grapheme clusters

      • OptionalsplitLimit: number

        Maximum number of substrings to return. As in native, anything past the limit is discarded, and the limit is converted with ToUint32 — so -1 means "no limit" while NaN and Infinity yield an empty array

      Returns string[]

      An array of strings, split at each point where separator occurs in the starting string. A regular expression's capture groups are interleaved into the result, as in native. Every entry is a string: a capture group that did not participate in its match is '' here, where native yields undefined. That makes it indistinguishable from a group that matched the empty string — use GraphemeString.split where the difference matters