Skip to content

split

String.split(target, source)

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"]