Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/string.ts>split

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function split
import { split } from "https://deno.land/x/fun@v2.0.0/string.ts";

Split a string into an array of strings at a character or RegExp match.

Examples

Example 1

import { split } from "./string.ts";
import { pipe } from "./fn.ts";

const bySpace = split(" ");
const byWhitespace = split(/\s+/);
const str = "Hello  There  World";

const result1 = bySpace(str); // ["Hello", "", "There", "", "World"]
const result2 = byWhitespace(str); // ["Hello", "There", "World"]

Parameters

separator: string | RegExp