Skip to main content
Module

x/fun/mod.ts>string.split

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

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