split

Split the provided array wherever a pattern instance is found, and return the resultant segments. The pattern is excluded from each of the segments.

Note that the src content is not duplicated by this function, but is sliced instead.

(Adapted from ocean.text.Util : split, which isn't memory safe.)

Template params: T = type of array element

  1. T3[] split(T1[] src, T2[] pattern, Buffer!(T3) result)
    T3[]
    split
    (
    T1
    T2
    T3
    )
    (
    T1[] src
    ,
    T2[] pattern
    ,
    ref Buffer!(T3) result
    )
  2. T3[][] split(T1[] src, T2[] pattern, T3[][] result)

Parameters

src T1[]

source array to split

pattern T2[]

pattern to split array by

result Buffer!(T3)

receives split array segments (slices into src)

Return Value

Type: T3[]

result

Examples

Buffer!(cstring) result;
split("aaa..bbb..ccc", "..", result);
test!("==")(result[], [ "aaa", "bbb", "ccc" ]);

Meta