(separator: string | RegExp): (self: string) => NonEmptyArray<string>
(self: string, separator: string | RegExp): NonEmptyArray<string>Splits a string into an array of substrings using a separator.
Example (Splitting strings)
import { pipe, String } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(pipe("abc", String.split("")), ["a", "b", "c"])
assert.deepStrictEqual(pipe("", String.split("")), [""])
assert.deepStrictEqual(String.split("hello,world", ","), ["hello", "world"])transforming
Source effect/String.ts:4567 lines
export const const split: {
(separator: string | RegExp): (
self: string
) => NonEmptyArray<string>
(
self: string,
separator: string | RegExp
): NonEmptyArray<string>
}
Splits a string into an array of substrings using a separator.
Example (Splitting strings)
import { pipe, String } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(pipe("abc", String.split("")), ["a", "b", "c"])
assert.deepStrictEqual(pipe("", String.split("")), [""])
assert.deepStrictEqual(String.split("hello,world", ","), ["hello", "world"])
split: {
(separator: string | RegExpseparator: string | RegExp): (self: stringself: string) => import NonEmptyArrayNonEmptyArray<string>
(self: stringself: string, separator: string | RegExpseparator: string | RegExp): import NonEmptyArrayNonEmptyArray<string>
} = import dualdual(2, (self: stringself: string, separator: string | RegExpseparator: string | RegExp): import NonEmptyArrayNonEmptyArray<string> => {
const const out: string[]out = self: stringself.String.split(separator: string | RegExp, limit?: number): string[] (+1 overload)Split a string into substrings using the specified separator and return them as an array.
split(separator: string | RegExpseparator)
return import readonlyArrayreadonlyArray.const isArrayNonEmpty: <A>(
self: ReadonlyArray<A>
) => self is NonEmptyArray<A>
isArrayNonEmpty(const out: string[]out) ? const out: string[]const out: {
0: string;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => string | undefined;
push: (...items: Array<string>) => number;
concat: { (...items: Array<ConcatArray<string>>): Array<string>; (...items: Array<string | ConcatArray<string>>): Array<string> };
join: (separator?: string) => string;
reverse: () => Array<string>;
shift: () => string | undefined;
slice: (start?: number, end?: number) => Array<string>;
sort: (compareFn?: ((a: string, b: string) => number) | undefined) => [string, ...string[]];
splice: { (start: number, deleteCount?: number): Array<string>; (start: number, deleteCount: number, ...items: Array<string>): Array<string> };
unshift: (...items: Array<string>) => number;
indexOf: (searchElement: string, fromIndex?: number) => number;
lastIndexOf: (searchElement: string, fromIndex?: number) => number;
every: { (predicate: (value: string, index: number, array: Array<string>) => value is S, thisArg?: any): this is S[]; (predicate: (value: string, index: number, array: Array<string>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: string, index: number, array: Array<string>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: string, index: number, array: Array<string>) => void, thisArg?: any) => void;
map: (callbackfn: (value: string, index: number, array: Array<string>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: string, index: number, array: Array<string>) => value is S, thisArg?: any): Array<S>; (predicate: (value: string, index: number, array: Array<string>) => unknown, thisArg?: any): Array<string> };
reduce: { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: Array<string>) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: Array<string>) => string, …;
reduceRight: { (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: Array<string>) => string): string; (callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: Array<string>) => string, …;
find: { (predicate: (value: string, index: number, obj: Array<string>) => value is S, thisArg?: any): S | undefined; (predicate: (value: string, index: number, obj: Array<string>) => unknown, thisArg?: any): string | undefined };
findIndex: (predicate: (value: string, index: number, obj: Array<string>) => unknown, thisArg?: any) => number;
fill: (value: string, start?: number, end?: number) => [string, ...string[]];
copyWithin: (target: number, start: number, end?: number) => [string, ...string[]];
entries: () => ArrayIterator<[number, string]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<string>;
includes: (searchElement: string, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: string, index: number, array: Array<string>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => string | undefined;
findLast: { (predicate: (value: string, index: number, array: Array<string>) => value is S, thisArg?: any): S | undefined; (predicate: (value: string, index: number, array: Array<string>) => unknown, thisArg?: any): string | undefined };
findLastIndex: (predicate: (value: string, index: number, array: Array<string>) => unknown, thisArg?: any) => number;
toReversed: () => Array<string>;
toSorted: (compareFn?: ((a: string, b: string) => number) | undefined) => Array<string>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<string>): Array<string>; (start: number, deleteCount?: number): Array<string> };
with: (index: number, value: string) => Array<string>;
}
out : [self: stringself]
})