split
ts
function String.split<T extends string, U extends RegExp>(
target: T,
delimiter: U,
): string[]Splits target string into an array of substrings using source string or regular expression as the separator.
Example
ts
import { String } from "@monstermann/string";
String.split("hello,world,test", ","); // ["hello", "world", "test"]
String.split("hello world", /\s+/); // ["hello", "world"]ts
import { String } from "@monstermann/string";
pipe("hello,world,test", String.split(",")); // ["hello", "world", "test"]
pipe("hello world", String.split(/\s+/)); // ["hello", "world"]