split¶
The split filter is designed to break down a string into an array of substrings based on a specified separator. This is a fundamental operation for working with delimited text, such as comma-separated values (CSV) or sentences separated by spaces.
Functionality
- Strings: Takes a string as input.
- Separator: Requires a string argument specifying the character or sequence of characters to use as the delimiter.
- Splitting: Divides the input string into substrings wherever the separator is found.
- Output: Returns an array containing the resulting substrings.
Syntax
Arguments- separator: A string representing the character or characters to use as the delimiter for splitting the string. If not provided, defaults to an empty string which will split the string by each character
Code Samples
Example 1: Splitting a Comma-Separated List
Output:
Example 2: Splitting a Sentence into WordsOutput:
Example 3: Splitting by CharacterOutput:
Outliers and Special Cases¶
- Empty Separator: If you provide an empty string as the separator (
""), the string will be split into an array of individual characters. - No Separator Found: If the separator does not occur within the input string, the output will be an array containing a single element (the original input string).
- Empty Input String: If the input string is empty, the filter returns an empty array.
- Non-String Input: If the input is not a string, the
splitfilter might attempt to convert it to a string or return an error, depending on how Experience Builder handles type conversions.
Key Points¶
- The
splitfilter is a fundamental tool for parsing and processing structured text data. - It is particularly useful when working with CSV files, log data, or other formats where data is separated by specific delimiters.
- Be aware that the behavior of the
splitfilter can be adjusted by providing different separator values.