Overview
The Split Text Block is used to split a string into an array of substrings based on a specified delimiter. This is useful when you want to separate a string into individual elements for further processing. The block allows you to specify the delimiter either directly in the block settings or dynamically via an input port. The delimiter can be any string, including special characters like newline (\n), tab (\t), and space ( ).
When entering special characters such as a new line in the block settings, put the literal character, not the escape sequence. For example, to split a string by a new line, press the Enter key to insert a new line in the block settings.
- Inputs
- Outputs
- Editor Settings
Inputs
| Title | Data Type | Description | Default Value | Notes |
|---|---|---|---|---|
| String | string | The string that should be split. | (required) | The input will be coerced into a string if it is not a string. |
| Delimiter | string | The delimiter to split the string by. This input is only available if Use Delimiter Input is enabled. | (empty) | The input will be coerced into a string if it is not a string. |
Example 1: Split a string into words
- Create a Text Block and set the value to
Hello, world!. - Create a Split Text Block and set the Delimiter to
,. - Connect the Text Block to the
Stringinput of the Split Text Block. - Run the flow. The
Splitoutput of the Split Text Block should contain the array["Hello", " world!"].
Example 2: Split a string into lines
-
Create a Text Block and set the value to:
-
Create a Split Text Block and set the Delimiter to
\n. -
Connect the Text Block to the
Stringinput of the Split Text Block. -
Run the flow. The
Splitoutput of the Split Text Block should contain the array["Hello,", "world!"].
Error Handling
The Split Text Block will error if theString input is not provided. If the Delimiter input or setting is not provided, the block will not split the string and will output the original string as a single-element array.
FAQ
Q: Can I split a string by multiple delimiters? A: No, the Split Text Block can only split a string by a single delimiter. If you want to split a string by multiple delimiters, you can use multiple Split Text Blocks in sequence. Q: Can I split a string by a regular expression? A: No, the Split Text Block does not support splitting a string by a regular expression. You can use a Code Block to split a string by a regular expression using JavaScript’ssplit() method.
Q: What happens if the delimiter is not found in the string?
A: If the delimiter is not found in the string, the Split Text Block will output the original string as a single-element array.

