@umbraco-cms/backoffice

    Function splitStringToArray

    • Splits a string into an array using a specified delimiter, trims whitespace from each element, and removes empty elements.

      Parameters

      • string: undefined | string

        The input string to be split and processed.

      • Optionalsplit: string = ','

        The delimiter used for splitting the string (default is comma).

      Returns string[]

      An array of non-empty, trimmed strings.

      const result = splitStringToArray('one, two, three, ,five');
      // result: ['one', 'two', 'three', 'five']
      const customDelimiterResult = splitStringToArray('apple | orange | banana', ' | ');
      // customDelimiterResult: ['apple', 'orange', 'banana']
    MMNEPVFCICPMFPCPTTAAATR