Splits a string into an array using a specified delimiter, trims whitespace from each element, and removes empty elements.
The input string to be split and processed.
Optional
The delimiter used for splitting the string (default is comma).
An array of non-empty, trimmed strings.
const result = splitStringToArray('one, two, three, ,five');// result: ['one', 'two', 'three', 'five'] Copy
const result = splitStringToArray('one, two, three, ,five');// result: ['one', 'two', 'three', 'five']
const customDelimiterResult = splitStringToArray('apple | orange | banana', ' | ');// customDelimiterResult: ['apple', 'orange', 'banana'] Copy
const customDelimiterResult = splitStringToArray('apple | orange | banana', ' | ');// customDelimiterResult: ['apple', 'orange', 'banana']
Splits a string into an array using a specified delimiter, trims whitespace from each element, and removes empty elements.