Function splitText

  • Split a text by multiple separators, and return a result of the text and separators. For example, splitText("Hello <and> world [then] !", ["<and>", "[then]"]) will return ["Hello ", new Separator("<and>"), " world ", new Separator("[then]"), " !"]

    Type Parameters

    • const S extends string[]

    Parameters

    • text: string
    • separators: S

    Returns (string | Separator<S[number]>)[]