Strings.splitAt()
Syntax
function splitAt(string: string, ...indexes: number[]): string[]
Splits the string at the given indices.
Parameters | |
string
|
The string to split. |
indexes
Rest
|
The indices to split at. These can be in any order. Negative indices will lead to an error. Duplicate indices are ignored. |
Example
import { Strings } from 'potence';
Strings.splitAt('banana', 2, 4); // -> ['ba', 'na', 'na']
Strings.splitAt('bànànà', 2, 4); // -> ['bà', 'nà', 'nà']
Remarks
Note that the indices correspond to characters, not code points. In other words: surrogate pairs are not broken apart.