A new array, with any elements previously containing more than one separator-separated entries now in separate elements.
import std.conv : to; { auto arr = [ "a", "b", "c d e ", "f" ]; arr = flatten(arr); assert((arr == [ "a", "b", "c", "d", "e", "f" ]), arr.to!string); } { auto arr = [ "a", "b", "c,d,e,,,", "f" ]; arr = flatten(arr, ","); assert((arr == [ "a", "b", "c", "d", "e", "f" ]), arr.to!string); } { auto arr = [ "a", "b", "c dhonk e ", "f" ]; arr = flatten(arr, "honk"); assert((arr == [ "a", "b", "c d", "e", "f" ]), arr.to!string); } { auto arr = [ "a", "b", "c" ]; arr = flatten(arr); assert((arr == [ "a", "b", "c" ]), arr.to!string); }
Flattens a dynamic array of strings by splitting elements containing more than one value (as separated by a separator string) into separate elements.